Jquery href Click




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/

Comments

Popular posts from this blog

Android App Version Update using the following cordova cli commands

75 inspirational quotes that will change your life

Retrieval Image From DataBase and Display on WebPage by Using Servlets.