我试图td通过使用Jquery和获取表格文本javascript
我有以下内容
//tables contain bunch of tables
for(var i = 0; i < tables.length ; i ++){
var table = tables[i];
$(table 'td').each(function(){ //I know there is something wrong with my selector.
$(this).text()
})
Run Code Online (Sandbox Code Playgroud)
该jquery选择并不在我的情况下工作.如何为不同的表选择每个td?
谢谢您的帮助!
我想你想用这个.find()方法:
$(table).find('td').each(function(){
Run Code Online (Sandbox Code Playgroud)
演示: http ://jsfiddle.net/jfj47/
当然,另一种方法是使用"上下文选择器":
$("td", table).each(function(){
Run Code Online (Sandbox Code Playgroud)
演示: http ://jsfiddle.net/jfj47/1/
此外,如果tables只是DOM元素的数组(或类数组对象),您不必循环并可以使用:
$(tables).find("td").each(function(){
Run Code Online (Sandbox Code Playgroud)
演示: http ://jsfiddle.net/jfj47/2/
参考文献:
find():http://api.jquery.com/find/| 归档时间: |
|
| 查看次数: |
71 次 |
| 最近记录: |