Javascript 单击复选框时停止触发功能

Javascript 单击复选框时停止触发功能,javascript,php,Javascript,Php,我正在使用jquery打印下表。表有两列。一个用于值,另一个用于复选框。 我面临的问题是,当我单击一个复选框时,它会触发该函数,而该函数应该仅在单击该值时才会触发 有人能告诉我如何在单击复选框时停止触发该功能吗 打印表的PHP代码 <table border='1' cellspacing='12' cellpadding='4' style='border-collapse: collapse' width='700' id=topictable > <?php while

我正在使用jquery打印下表。表有两列。一个用于值,另一个用于复选框。 我面临的问题是,当我单击一个复选框时,它会触发该函数,而该函数应该仅在单击该值时才会触发

有人能告诉我如何在单击复选框时停止触发该功能吗

打印表的PHP代码

<table border='1' cellspacing='12' cellpadding='4' style='border-collapse: collapse' width='700' id=topictable >

<?php while ($row = mysql_fetch_assoc($results)) {
    $topic = $row['topic']; 
?>
<tr bgcolor='white'>
<td class='value'><a href='#'><?php $topic ?></a></td>
<td bgcolor='white'width='5%'><input type=checkbox name=chekboxTopic[] value= <?php $topic ?> </td>
</tr>
<?php
}
?>
</table>
两件事

  • 关闭你的输入
  • 更改应该单击的内容;让它更具体

  • 演示:

    
    
    html中的id
    topictable
    在哪里?已更正。现在应该可以看到了。根据我的推测,这一行是不正确的:
    
    
    $(document).on("click","#topictable td", function() {
        // to set the session variable`enter code here`
        var strSelectedTopic = ($( this ).text());
        alert(strSelectedTopic);
        var switchval = "setsessiontopic";
         var param = "switchval=" + switchval + "&topic=" + strSelectedTopic;
         ajaxSend(param);
        var form = document.getElementById("abcd");
        form.action = "design.php"
        form.target = "_blank";
        form.submit();
        return false;
    
    });
    
    <table border='1' cellspacing='12' cellpadding='4' style='border-collapse: collapse' width='700' id=topictable >
    <?php
        while ($row = mysql_fetch_assoc($results)) {
            $topic = $row['topic'];
    ?>
        <tr bgcolor='white'>
            <td class="value"><a href="#"><?php $topic ?></a></td>
            <td bgcolor="white" width="5%"><input type="checkbox" name="chekboxTopic[]" value="<?php $topic ?>" /></td>
        </tr>
    <?php
        }
    ?>
    </table>
    <script>
    // Click on the class ".value" not "td", that is too broad
    $(document).on("click","#topictable .value", function() {
        // to set the session variable`enter code here`
        var strSelectedTopic = ($(this).text());
        alert(strSelectedTopic);
        var switchval   =   "setsessiontopic";
        var param       =   "switchval="+switchval+"&topic="+strSelectedTopic;
        ajaxSend(param);
        var form        =   document.getElementById("abcd");
        form.action     =   "design.php"
        form.target     =   "_blank";
        form.submit();
        return false;
    });
    </script>