tags:

views:

45

answers:

2

Hello,

I have div in which I have added 5 files, using appendTo, Now I want to get the src of all these files. How do I go about getting it using jQuery. can I use .get()?

Thanks Jean

[edit]

<div id="some">
<img src="jquery_book.jpg"><a href="jquery.pdf">JQuery Book</a>
</div>

I need src and href.

+1  A: 

Not sure what you meant by the file but you can get attribute like this:

$("selector").attr('src');

Based On Your Updated Answer:

$('#some a').each(function(){
    alert ($(this).attr('href'));
});
Sarfraz
+2  A: 
rahul
Is it necessary to use an array?
Jean
This will get all your source path in an array, and you can iterate through the array and take individual values. If you don't want to use an array then do your manipulations inside itself. Updated the answer
rahul
I am triggering the even and appending a div for test purpose('#some1').appendTo('#div_id).attr(src);Or is it wrong?
Jean
Will there be divs with ids some1, some2 etc
rahul