javascript - Trying to get td row text when clicking on td after it -
i want contents of row when click on div in row after it
html:
<td class="ms-cellstyle ms-vb2">10</td> <td class="ms-cellstyle ms-vb2"> <div class="ms-chkmark-container"> <div class="ms-chkmark-container-centerer"><span class="ms-cui-img-16by16 ms-cui-img-cont-float" unselectable="on" style="z-index:0"><img id="2,10,chk" liid="10" shouldanimate="1" lid="{00124e2c-bfcd-4501-8668-efaf8e6416d2}" tabindex="0" title="mark task complete." class="js-chkmark ms-chkmark-notcomplete" src="/_catalogs/theme/themed/626bdbfa/spcommon-b35bb0a9.themedpng?ctag=11" unselectable="on" hascheckmarkhandler="1"></span> </div> </div> </td>
js:
var itemid = $("div .ms-chkmark-container").click(function () { var id = $(this).closest("td").prev().html(); console.log(id); return id; })
why don't go parent() instead of prev()?
var id = $(this).parent().prev().html();
haven't tried though, should work.
you can point click td , use $(this).
Comments
Post a Comment