HTML Code
<a class="sign_new" href="#sign_up" data-value="110">Sign up</a>
JavaScript+jQuery 1.8.3
$(document).ready(function(){
$('a[href="#sign_up"]').click(function(){
alert('Sign new href executed.');
var a = $(this).data("value");
alert(a);
});
});
To add a certain value to anchor tag?
<a href="#" data-value="1">Text</a>
<script type="text/javascript">
$("a").click(function(){
i=$(this).data("value");
$('#square').animate({'left': i * 360});
});
</script>
DEMO: http://jsfiddle.net/pnGbP/
No comments:
Post a Comment