杂记c-----小写金额转化成大写数字;点击表格table时,当前被点击的tr行变色,其它行不变色;input隐藏显示
public string chang(string money) { //将小写金额转换成大写金额 double MyNumber = Convert.ToDouble(money); String[] MyScale = { "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾", "佰", "仟" }; String[] MyBase = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; String M = ""; bool isPoint = false; if (money.IndexOf(".") != -1) { money = money.Remove(money.IndexOf("."), 1); isPoint = true; } for (int i = money.Length; i > 0; i--) { int MyData = Convert.ToInt32(money[money.Length - i].ToString()); M += MyBase[MyData]; if (isPoint == true) { M += MyScale[i - 1]; } else { M += MyScale[i + 1]; } } return M; }
query实例:点击表格table时,当前被点击的tr行变色,其它行不变色
<script language="javascript"> //假设Table的ID为angel $("#angel tr").click(function(){ $(this).addClass("on").siblings("tr").removeClass("on"); }); </script>
上面代码中的意思:
addClass:是添加样式;
siblings:是用来获取同辈元素,siblings("tr")的意思就是获取同辈的tr元素;
removeClass:是去除样式;
input隐藏显示
function select(Type) {
if (Type == 1) {
$("input[id='addBtn']").show();
}
if (Type == 2) {
$("input[id='updateBtn']").show();
}
};