Currently i am using this to modify the "html" of a specific "column/cell" by finding the "td" of the "grid" at specific "rows".
$("#VGrid1_MainGrid tr:nth-child(" + iRowNumberGrid + ")").find('td').eq(26).html("HTMLHERE");
After that is done, how do I [ (a) access, (b) modify ] the individual "div1/div2" content that is in it for the "Grid" at particular "row" and "column"? RowNumber = 2, column = 26
<td>
<div class="myclass">
<div id="div1">Access content</div>
<div id="div2">Add/Modify content</div>
</div>
<td>
Thanks to all for the answer. I like best is this with just a single line.
$("#VGrid1_MainGrid tr:nth-child(" + iRowNumberGrid + ")").find('td').eq(26).find('#div1').html('stuffhere');
Try this
var td = $("#VGrid1_MainGrid tr:nth-child(" + iRowNumberGrid + ")").find('td').eq(26);
td.html("HTMLHERE");
$("#div1", td).html("foo");
$("#div2", td).html("bar");
Do not mess with the 4. row 26. column. This is a bad development practice. Instead you should give an id or class to exact column then select it with jQuery and do what you want to do. such as
var col = $('#row4column26'); // this will select you 26th column at 4th row col.find('#div1').html('HTMLHERE'); // select the div1 in the column and change its content col.find(('#div2').html('HTMLHERE'); // the same for div2
When you have your element at the specified index:
$("#VGrid1_MainGrid tr:nth-child(" + iRowNumberGrid + ")").find('td').eq(26)
You can use this
to access something inside. Like so:
$("#VGrid1_MainGrid tr:nth-child(" + iRowNumberGrid + ")").find('td').eq(26).each(function()
{
$(this).html("HTMLHERE");
$('#div1',this).doSomething();
});
Or even make your own selector a bit shorter:
$("#VGrid1_MainGrid tr:nth-child(" + iRowNumberGrid + ") td").eq(26).each(function()
{
$(this).html("HTMLHERE");
$(this).find('#div1').doSomething();
}
当您已经找到div所在的列时(上面的代码),您可以在列的jQuery对象上使用.find('#div1')来检索div并使用.html('stuffhere')进行修改
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.