I have the script as as follows: I want to inclde th index va开发者_如何学JAVAlue as shown below. How can I do that? With my actual code,I am having error
for(var index = 1; index < 6; index++){
$("#myTable thead td:nth-child(index + 2).html("here");
}
You could do:
for(var index = 1; index < 6; index++){
var nthchild = index+2;
$("#myTable thead td:nth-child("+nthchild+")").html(index);
}
You have to write:
for(var index = 1; index < 6; index++) {
$("#myTable thead td:nth-child("+(index+2)+")").html("here");
}
Concatenate string, and sorted your syntax error:
for(var index = 1; index < 6; index++)
{
$("#myTable thead td:nth-child(" + (index+2) + ")").html('here');
}
精彩评论