I am trying to get the element inside of the dynamically created ID, to alert. So far i've this.
<tr>
<td class="td-input">
<input id="WILL GENERATE DYNAMICALLY IP" type="checkbox"
onchange="toggleSelect(this,event)" class="update-select-widget">
</td>
<td>127.0.0.1</td>
<td></td>
<td>
<div onclick="singleLaunch(this)"><i class="fa fa-gear"></i></div>
</td>
</tr>
function:
var nestedId = $(this).parent().parent().children(".td-input").attr("id");
alert(nestedId);
there is plenty of tables with different values, ill have to showcase, i tried using .each and .map in the past but still not luck. Best Regards
this
cannot be used if you are calling this using onclick
attribute.
function singleLaunch(div){
alert($(div).closest('tr').find(".td-input input").attr("id"));
}
function singleLaunch(x){
var nestedId = $(x).closest("tr").find(".td-input input").attr("id");
alert(nestedId);
}
Try this
$(document).on('click', '.td-input input', function(){
alert($(this).attr('id'));
});
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.