Hi guys,
Can anyone please help me with this simple error. Jquery is not my strongest suite but I feel like this is something small that I'm missing. With the code below I get the error 'undefined'.
html:
<a href='#' ><img src= "./images/1.jpg" width= '200px' id="2" rel="arm1" onclick = 'test()' /></a>
Jquery:
function test(){
alert($(this).html());
};
What I want is the HTML code of the img tag being clicked on. Is there another way to do this?
So I've tried the following and it doesn't work aswell: I've added the onclick to the ahref tag aswell.(error : undefined) I've tried passing by 'event' as a parameter. (error stating ev is not declared) when trying to get its html().
PS I do not want to use the id as a onclick function!
Anyhelp will be very much appreciated!
Thanks!