i have 3 images with the same id="UserImages" i wanted to know if i can click on them and get the scr in jquery?
+8
A:
First I'd switch them to classes (IDs must be unqiue):
<img class="UserImages" src="..." />
Then use a .class
selector to find them, like this:
$("img.UserImages").click(function() {
alert(this.src);
});
Nick Craver
2010-10-14 13:16:58
how would i get only the file name not the whole address?
Gully
2010-10-14 13:34:33
@Gully - There's a few easy options for that, check out these questions: http://stackoverflow.com/questions/605696/get-file-name-from-url, http://stackoverflow.com/questions/1302306/how-to-pull-the-file-name-from-a-url-using-javascript-jquery
Nick Craver
2010-10-14 13:36:54