例如在jsp中的<table><tr><td><input name="userName" value="默认值" onclick="change(this);"><td><td></td></tr></table>
js中有函数
<html>
<head>
function change(node){
这里写你的操作
}
function choice(node){
}
</head>
<body>
<div id="tempShow">
<table>
<tr id="">
<td><input name="userName" value="默认值" onclick="change(this);"/></td>
<td><input name="hobby" type="checkbox" onclick="choice(this);">JAVA</td>
</tr>
<tr id="">
<td></td>
<td></td>
</tr>
</table>
</div>
</body>
</html>
复选框是否被选中
$(node).parent().parent().find("input[type='checkbox']").is(':checked');
返回值为true / false
更改复选框状态
$(node).find("input[type='checkbox']").attr("checked",false);
改为未选状态隐藏(显示)行
$(node).parent().parent().find("#id").hide();
$(node).parent().parent().find("#id").show();
更改value或者text值
获取值$(node).val();
获取文本$(node).text();
更改值$(node).val('要修改的值');
更改文本$(node).text('要修改的值');
获取行数
$("tr[id^=id_]").length;
这里使用了正则表达式获取所有以id_开头的行获取修改style中的属性
$(node).parent().parent().find("div#tempShow").css("display");
获取
$(node).parent().parent().find("div#tempShow").css("display","none");
隐藏字符串分割成数组
string.split('分隔符');
字符串截取
string.substring(startIndex,endIndex);
复制
$(node).clone();
追加
$(node).append();
$(node),after();
$(node).before();
删除
$(node).remove();
$(node).empty();
找到第一个或最后一个元素
$(node).parent().first();
$(node).parent().last();
转换成json数组格式
JSON.stringify(data);
这是使用后总结的一点比较基本的操作,基本包括了增删改查得操作。更多操作后续会继续分享