押す方法を考えてEnterいましたが、対象の要素に特定のクラスが存在する場合はそうではありませんか?
jQuery("#input").keypress(function (e) {
if (e.keyCode == 13 && jQuery('.classTest').not(this)) {
//any item selected with enter EXCEPT which has .classTest
}
});
?
PS使用.input
!IDは1つの要素専用です。
jQuery(".input").keypress(function (e) {
if (e.keyCode == 13 && !(jQuery(this).hasClass('classTest')) ) {
alert('enter!');
}
});
使用されるコード:
!( $(this).hasClass('classTest') )
!=
jQuery APIではありません.hasClass()