在< a>上动态添加href [英] Dynamically add href on <a>

查看:146
本文介绍了在< a>上动态添加href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个注销链接

  <div id="titleInfo">
      <div id="signOut">
          <a href="" class="signOutLink"  >Log Out</a>
      </div>
  </div>

我需要动态添加导航目标.

I need to add navigation destination dynamically.

$(document).ready(function() {
    //Navigation Handling
    $('.signOutLink').click(function() {
        alert('h');
        window.location.href("LogOut.aspx");
        //window.location.replace("LogOut.aspx");

    });
});

但是它不起作用.我们该如何纠正呢?

But it is not working. How can we correct it?

推荐答案

感谢所有人.我使用了以下内容:

Thanks to all. I used following:

$('.signOutLink').click(function () {
    window.location.href("LogOut.aspx?a=b"); //Can use REPLACE also
    return false;  //FALSE

});

这篇关于在&lt; a&gt;上动态添加href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆