html - Execute JQuery Function For Each Element -


I am trying to execute a JQuery function which is empty in the divan for each element (if it is empty). Under the id "answerrr", however, the script will only search for the first part and add text to it, and it will ignore the rest. Maybe I am using the .each () function incorrectly?

  & lt; B & gt; & Lt; Div id = "answerrr" & gt; & Lt; / Div & gt; & Lt; / B & gt; & Lt; B & gt; & Lt; Div id = "answerrr" & gt; & Lt; P & gt; Not blank & lt; / P & gt; & Lt; / Div & gt; & Lt; / B & gt; & Lt; B & gt; & Lt; Div id = "answerrr" & gt; & Lt; / Div & gt; & Lt; / B & gt; & Lt; Script & gt; $ ('' '' '' '' '' '' '' '($' ' Gt; ') Attachments ($ (this));}}); & Lt; / Script & gt; In addition, if my page has to load more content through Ajax, then how do I go to make sure that this script is re- Your basic problem is that for many elements HTML is not the same ID. Use a square instead.  

After deciding this, do not use the same selector again within .each calls, just $ (this) the current element To refer.

You can also remove the : blank exam from the loop and just make it a part of the selector, and since the .append But you will be able to really get rid of the .each loop, just create your whole code:

  $ ('answerrr : Empty '.) Attached (' 

Empty & lt; / p ') ;!

Look for the work demo.

Added later for content, just make sure that the above code is applied as part of the .one callback from AJX load.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -