Solved

jquery contains method to look for a paragraph tag

Posted on 2016-10-19
2
23 Views
Last Modified: 2016-10-19
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
Comment
Question by:maqskywalker
2 Comments
 
LVL 6

Accepted Solution

by:
Thomas Wheeler earned 500 total points
Comment Utility
This is one way
$('.DivStyle1>p').append(img); 

Open in new window


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

Open in new window

0
 
LVL 1

Author Closing Comment

by:maqskywalker
Comment Utility
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to dynamically set the form action using jQuery.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now