Solved

jquery contains method to look for a paragraph tag

Posted on 2016-10-19
2
29 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 7

Accepted Solution

by:
Thomas Wheeler earned 500 total points
ID: 41851252
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
ID: 41851317
thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

808 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