Reputation: 5343
In our application we are using set of images as slides. If we click one image we want to get the id of the in the same page. i have tried by using the following code.
code: HTML:
<a id="100" href="#"> <img scr="..."/> </a>
...
JQUERY code:
$("div.alb a").click(function() {
});
Problem:
Without href="#" the click event is not working.
I want to get the id by clicking the image without using server control.
Without using server control is it possible to achieve this task.
Geetha.
Upvotes: 0
Views: 1512
Reputation: 85845
It seems to work for me without using herf.
You can check it out here.
I can't get a image to show up when using jsbin not sure why though.
$(function()
{
$("a").click(function()
{
var test = $(this).attr('id');
alert(test);
});
});
Upvotes: 0
Reputation: 9493
html:
<img src="..." id="i100"/>
js (jquery):
$('img[id]').click(function(){
var my_id = $(this).attr('id');
return false;
});
otherwise, if you cant modify your html-code just add 'return false' to prevent redirect.
Upvotes: 2