JQuery的事件中使用this

先看下面代码:

name sex age
Henry male 30
Emily female 30
上面是含有change事件的表格,下面是change事件的实现 function onChange(id){ $("input[name='tdCheckBox']").removeAttr('checked'); id.checked = true; console.log(id.checked) var name= id.parentNode.parentNode.children[1].textContent; console.log(name); } 重点是id.parentNode.parentNode.children[1].textContent; 获取对象的内容,也可使使用innerHTML; 主要是children的使用可以获取指定行的对象。

猜你喜欢

转载自www.cnblogs.com/scyitgz/p/13378568.html