[ACCEPTED]-how to get rel value of clicked element-return-value
If you're using a button with an ID, then 7 you shouldn't have to get any extra data 6 from the rel attribute since the function 5 is unique to your button.
But if you have 4 other reasons, then you just need to make 3 sure your button itself has a rel attribute 2 defined, e.g.
<input id="forwardStep" rel="test" type="button" value="forward" />
and your function is closed 1 properly
$(document).ready(function(){
$('#forwardStep').bind('click',function(){
var page = $(this).attr('rel');
alert(page);
})
})
Because it wasn't ever defined? Where's 2 the html? Are you sure you're targeting 1 the right element?
$(this) will give you whatever element has 8 the id of "#forwardStep", so for this example 7 to work it should be a link or anchor, but 6 you said it was a button.
I don't think 5 a button can have a rel attribute. If you 4 are trying to get the rel attribute from 3 a link you'll need to selct that link rather 2 than "this". e.g. $('#theLinkId').attr('rel').
You 1 should add the HTML to this question.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.