Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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 Jquery是否排除单击时的第一个td事件?_Javascript_Jquery - Fatal编程技术网

Javascript Jquery是否排除单击时的第一个td事件?

Javascript Jquery是否排除单击时的第一个td事件?,javascript,jquery,Javascript,Jquery,如何排除我在下面创建的jquery的click事件上的第一个td?我想排除生成对话框的单击事件上所有第一行的td jQuery("#list tbody tr").click(function(){ //some code here }); <table> <tr> <td>first</td> <td></td> <td></td>

如何排除我在下面创建的jquery的click事件上的第一个td?我想排除生成对话框的单击事件上所有第一行的td

jQuery("#list tbody tr").click(function(){

//some code here

});

<table>
    <tr>
        <td>first</td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>first</td>
        <td></td>
        <td></td>
    </tr>
</table>
jQuery(#list tbody tr”)。单击(函数(){
//这里有一些代码
});
第一
第一
将选择器与以下各项结合使用如何:

示例:

顺便说一句,你是从哪里弄来的?此外,您的表需要一个id=“list”,因此:


第一
第一
试试这个

jQuery("#list tbody tr").each(function() {
    jQuery("td:not(:first)",this).click(function() {
        alert($(this).text());
        //some code here
    });
});

请记住,您在html中也使用了tbody,不管它是第一个还是中间的,我通常会在
td
上放置一个属性,表示
noclick
,并执行如下操作:

<table>
    <tr>
        <td></td>
        <td noclick></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td noclick></td>
        <td></td>
    </tr>
</table>

JSFIDLE:

出现错误……我的数据取决于我的整个表行。这里@mocca:我不知道你的意思——你能提供更多细节吗?
jQuery("#list tbody tr td:not(:first)")
$('#list tr td:not(:first)').click(function() {
    // ...
})
<table id="list">
    <tr>
        <td>first</td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>first</td>
        <td></td>
        <td></td>
    </tr>
</table>
jQuery("#list tbody tr").each(function() {
    jQuery("td:not(:first)",this).click(function() {
        alert($(this).text());
        //some code here
    });
});
<table>
    <tr>
        <td></td>
        <td noclick></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td noclick></td>
        <td></td>
    </tr>
</table>
$('table tr td:not([noclick]').on('click', (obj) => {
    let el = obj.currentTarget;
  
  $(el).css('background-color', 'red');
});