zjj-coder
//这是点击绑定按钮
<input type="button" value ="为<a>标签绑定的按钮" onclick="a();"/>
//这是class="gs-title"的<a>标签
<a class="gs-title" href="http://news.sina.com.cn/area/sh.shtml" target="_blank" dir="ltr"><b>上海</b>地区_新闻中心_新浪网</a>
View Code

 

 
//这是按钮的函数,为了将class为.gs-title的<a>标签绑定click函数
function a()
 {
 
    $(".gs-title").bind(\'click\', function() {
        alert($(this).attr("href"));
        window.location.href=\'www.baidu.com\';
        return false; 
        
    });
 
 }

只要return false 就可以阻止跳转,并且还可以执行新的跳转函数。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2021-08-21
  • 2022-02-17
  • 2021-08-21
猜你喜欢
  • 2021-08-21
  • 2022-02-09
  • 2021-12-22
  • 2021-10-28
相关资源
相似解决方案