0

I am trying to concatenate my div to images within it using jquery variable. Not sure how to do this. Thanks for any helps.

var pictureDiv = $('#pictureDiv');

pictureDiv.css('height','500');

//I want to change image within my pictureDiv and 
//want to use my pictureDiv variable..
pictureDiv.img??

//I also want to change p tag within my pictureDiv and
// want to use my pictureDiv variable..
pictureDiv.p??
2
  • You're looking for .find(), as in pictureDiv.find('img') or whatever. Commented Aug 9, 2012 at 1:08
  • Use the .find() method for everything inside an element Commented Aug 9, 2012 at 1:10

3 Answers 3

3

If the picture div has <p> tags in it, is it the actual image or a container that contains both <p> tags and <img> tags? If it's a container, use the .find() function like this:

pictureDiv.find('img').attr('src',SomeValue);
pictureDiv.find('p')....
Sign up to request clarification or add additional context in comments.

Comments

2

if you have p tag and img tag in pictureDiv

var pictureDiv = $('#pictureDiv');

pictureDiv.css('height','500');

$("img",pictureDiv).attr("src","image path");

$("p",pictureDiv).html("insert text into p tag");

Comments

1

jQuery('#pictureDiv').find("img"); jQuery('#pictureDiv').find("p");

This should get you the list of images.

That is if I understood the question correctly.

hth

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.