How to change HTML link's href property dynamically

后端 未结 2 972
梦毁少年i
梦毁少年i 2021-01-22 13:59

Hi I have a HTML link on my MVC3 View.

I want to change its href property each time user clicks it.



        
2条回答
  •  遇见更好的自我
    2021-01-22 14:40

    $("a.tabs").click(function() {
        this.href = 'newhref';
        return false;
    });
    

    It is more efficient this way compared to @ocanal solution.

    Source:

    http://net.tutsplus.com/tutorials/javascript-ajax/14-helpful-jquery-tricks-notes-and-best-practices/

提交回复
热议问题