javascript - jQuery replace strings in many classes -


I am trying to use jQuery to change all the frequencies of a particular string that would be in a certain class is. There are several sections of this type on the page.

So far I have the following code:

  var el = $ ('div.myclass'); If (L! = Null & amp; el.html ()! = Null) replace {el.html (LLL (HLH)) (/ this / ig, "that")); }  

This does not work if there is more than one div from class myclass . If there is more than one div then the second one is replaced with the previous material! It looks like jQuery replaces the first device and with its result it changes all sections of myclass .

Does anyone know how I should do this? I am thinking of some kind of loop on all the examples of mychass divs - but my JS is a little weak.

A little difference in the previous answer:

  $ ('div Myclass'). Every (function (i, el) {if ($ (el) Html ()! = "") {$ (L). Html ($ (el) .html (). Replace (/ it / ig, "that "));}});  

should work


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -