Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 表行中的超链接问题_Javascript_Html_Twitter Bootstrap - Fatal编程技术网

Javascript 表行中的超链接问题

Javascript 表行中的超链接问题,javascript,html,twitter-bootstrap,Javascript,Html,Twitter Bootstrap,我有一个由循环(PHP)生成的表行。我已经转换了链接中的整行,但问题是行上有一个。每次我选中该框时,页面都会重定向,因为上的数据href。 我想知道的是,是否有方法阻止或停止复选框重定向,并且复选框继续正常工作 HTML: 解决方案(编辑): 在jQuery代码中使用preventDefault(),如下所示: jQuery(document).ready(function($) { $(".active-row").click(function(e) { e.preventDefaul

我有一个由循环(PHP)生成的表行
。我已经转换了链接中的整行,但问题是行上有一个
。每次我选中该框时,页面都会重定向,因为
上的
数据href
。 我想知道的是,是否有方法阻止或停止复选框重定向,并且复选框继续正常工作

HTML:

解决方案(编辑):

jQuery
代码中使用
preventDefault()
,如下所示:

jQuery(document).ready(function($) {
    $(".active-row").click(function(e) {
e.preventDefault();            
    });
});

我想你应该像这样检查当前点击的项目

 jQuery(document).ready(function($) {
        $(".active-row").click(function() {
            if(!$(this).is(':checkbox')){
                 window.document.location = $(this).data("href");
            }
        });
    });
首先在复选框中添加一个“catcher”单击,然后添加另一个单击处理程序:

$(".active-row td input").click(function(e) {
    e.stopPropagation();
});

$(".active-row td").click(function(e) {

    window.document.location = $(this).data("href");
});

您正在将超链接设置为整个表体的属性。根据你想要什么,我建议你重新设计你想要的超链接。好的。。。谢谢你的创意!!!我唯一的问题是这个链接已经不起作用了,但是谢谢你的创意。很好。。。非常好,@Axel它工作得非常完美,完全符合预期。我只做了一些调整,但它的工作!!!谢谢
jQuery(document).ready(function($) {
    $(".active-row").click(function(e) {
e.preventDefault();            
    });
});
 jQuery(document).ready(function($) {
        $(".active-row").click(function() {
            if(!$(this).is(':checkbox')){
                 window.document.location = $(this).data("href");
            }
        });
    });
$(".active-row td input").click(function(e) {
    e.stopPropagation();
});

$(".active-row td").click(function(e) {

    window.document.location = $(this).data("href");
});