javascript - Pass variable to getElementById -
i have multiple tables generated loop , each table have different ids. (table1,table2,table3 , on.) want pass these id getelementbyid function using jquery each function. here code
$(document).ready(function () { $('.table', this).each(function (index, element) { tnames = $(element).attr('id'); //alert(tnames) var elem5 = document.getelementbyid(tnames); alert(elem5); }); });
tnames alert fine. when pass tname getelementbyid
function return null or object. want should return ids returning alert(tname)
;
any , suggestions. please?
i hope following code find element's id. following code alert table id.
$("document").ready(function () { var tableid= $('table').attr('id'); var element = document.getelementbyid(tableid); alert(element.id); });
Comments
Post a Comment