Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re write innerHTML in jQuery

I have the following in my js.

for (var i = 0; i < this.length; i++) {
this[i].innerHTML = thehtmlval;
}

I want to write the same in jQuery.

I did some search and saw this but dont know how to apply it in this case. Can someone please help.

like image 792
harsh Avatar asked Jan 14 '23 02:01

harsh


1 Answers

Assume this in your code is a NodeList:

$(this).each(function() {
  $(this).html(thehtmlval);
});

Or just: $(this).html(thehtmlval); because jQuery already did the loop for you inside.

like image 89
xdazz Avatar answered Jan 23 '23 15:01

xdazz