javascript - Is it possible to set ID and Class of an element using jQuery method attr()? -
$("selector").attr("id","idname");
is possible use above setting id or class of element.
hm feel i've said thousands of times. jquery class selector returns array of html elements class. so, if want data form elements need loop on array or access directly.
$('.gg1').first().attr("id"); //returns id of first element class gg1 $('.gg1')[1].attr("id"); //returns id of second element class gg1 for(var = 0; < $('.gg1').legth; i++= { console.log($('.gg1')[i]); } //loops on cormplete html collection
Comments
Post a Comment