gpt4 book ai didi

jquery - 我如何拒绝在特殊项目上触发的事件

转载 作者:行者123 更新时间:2023-12-01 03:40:35 25 4
gpt4 key购买 nike

我有一个带有一些输入的 div。现在,每当我的输入发生变化时,我想触发该事件。到目前为止,一切都很好:)但如果我选择带有第一个输入的文件,我不希望事件被触发。

see my Fiddle

这是来源

HTML:

<div class="someForm">
<input type="file" name="logo" class="logoselector" />
<br />
<div class="row-fluid">
<input type="text" name="firmenname" />
<br />
<input type="text" name="adresse" />
<br />
<input type="text" name="telefon" />
<br />
<input type="text" name="fax" />
</div>
</div>

这是jquery

$('.someForm').on('change', function(){
alert('changed');
});

我已经尝试了一些带有 :not(...) 的构造,但没有结果 :/

最佳答案

使用 :not() 尝试此操作和 :first

$('.someForm input:not(:first)').on('change', function(){
alert('changed');
});

这样 jQuery 将查找所有输入,但不是第一个::not(:first)

Demo

<小时/>

您还可以使用 :file 来定位 file 类型。里面:not()

喜欢:

$('.someForm input:not(:file)').on('change', function() {
alert('changed');
});

Demo

关于jquery - 我如何拒绝在特殊项目上触发的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21533573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com