Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

jquery contains method to look for a paragraph tag

Hi experts,

I have this fiddle

https://jsfiddle.net/k0nfs2e9/

it looks like this:
fiddle
In this fiddle i'm doing this:

// look for all elements using this class DivStyle1 and append the image to the one that contains this string Div 3
$('.DivStyle1:contains("Div 3")').append(img);  

That works fine.

How do i revise it, so it instead of looking for this string "Div 3"  I look for the <p> tag instead.

I tried this but it didn't see to work:

// look for all elements using this class DivStyle1 and append the image to the one that contains this tag <p>
$('.DivStyle1:contains("<p>")').append(img);  

Any ideas of what I'm doing wrong?
0
maqskywalker
Asked:
maqskywalker
1 Solution
 
Thomas WheelerCommented:
This is one way
$('.DivStyle1>p').append(img); 

Open in new window


 $('.DivStyle1>p:contains("Div 3")').append(img);   

Open in new window

0
 
maqskywalkerAuthor Commented:
thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now