I believe he/she is binding an event with javascript not jquery's event binding.

Webmaster you can refer to an element which was clicked with "this"
keyword. So to get your image source just use "this.src" property.

Example:

<img src="..." onClick="alert(this.src)" />

The same when applying with event listeners...

-------------
Read jQuery HowTo Resource  -  http://jquery-howto.blogspot.com



On Mon, Jan 12, 2009 at 6:05 PM, Mauricio (Maujor) Samy Silva
<css.mau...@gmail.com> wrote:
>
> $('img').click(function() {
> var fileName = $(this).attr('src');
> alert(fileName);
> });
>
> MaurĂ­cio
>
> -----Mensagem Original----- De: <webmas...@terradon.nl>
> Para: "jQuery (English)" <jquery-en@googlegroups.com>
> Enviada em: segunda-feira, 12 de janeiro de 2009 10:59
> Assunto: [jQuery] How to grab the filename (src attribute) of an image?
>
>
>>
>> Hi all,
>> how do i grab the filename of an image?
>>
>> Situation now:
>> i use "normal" javascript when clicking on an image and just inserted
>> some jquery to post gamedata to update a gamepage with the help of the
>> taconite plugin (returns xml-data), so far so good.
>>
>> I just miss one item => i need the filename (src attribute of the
>> image) of the image on which was clicked, ut just can't figure out how
>> to grab it.
>>
>> Thanks in advance for your help.
>>
>>
>
>

Reply via email to