Search code examples
jquerymenuweblnk

jQuery menu using <a> tags


I'm making a very basic menu but I can't seem to get it to work. I'm using jQuery for it. Here's what I have so far.

<script>
$(document).ready(function(){
    $("a#lnk").click(function(){
        top.location.href="http://"+this.lnk
    });
});
</script>

I've used a custom "lnk" attribute to store the site link. Can anyone help?


Solution

  • You should do

    $("a#lnk").click(function(){
      top.location.href="http://"+$(this).attr('lnk');
    });
    

    but this makes no sense to me, because it's already a link and you shuold use the href attribute