javascript - Target only one element with jQuery -


I have a small problem with my code, and though I can stack overflow people know how to To solve.

Here's the scenario:

I have to add strong inside p to another element that will have post captions. I am able to solve it, but I am having problems. Photo caption duplicates in other similarly named elements, which I do not want to do. So the post caption can be in the post, but not always, but it still has to work.

HTML

  & lt; Div class = "post" & gt; & Lt; P & gt; Advertising for advertising did not matter either at any time; Information about Donak Penders at Morris Laurem & Lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "post" & gt; & Lt; P & gt; Advertising for advertising did not matter either at any time; Information about Donak Penders at Morris Laurem & Lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "post" & gt; & Lt; P & gt; Advertising for advertising did not matter either at any time; Information about Donak Penders at Morris Laurem & Lt; / P & gt; & Lt; P & gt; & Lt; Strong & gt; This is the caption. & Lt; / Strong> & Lt; / P & gt; & Lt; / Div & gt;  

JS

  var $ caption = $ ("strong: first-child"). Text (); Var $ removable = $ ("strong post: first-child"); $ ("Strong: first-child"). mother-father (). Remove (); $ Removable.remove (); $ ("Post"). App ("& lt; p class = 'post-caption' & gt;" + $ Caption + "");   

Div class = "post -text "itemprop =" text ">

$ (" strengthen: first-child "). mother-father (). Remove (); In strong each .post first.

If you want the first .post you want to $ ('(' strong ''); or $ ('.post: first -Bar strong ');


Comments

Popular posts from this blog

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

c# - Chart control: Design messed Up after clearing and re-adding Y-Values -

ruby on rails - Apipie interferes with proper error codes -