jQuery排除选择器? [英] Jquery Exclude a Selector?

查看:98
本文介绍了jQuery排除选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个明确的重点表.我选择了整个表单,除了单击提交"按钮为空白外,它的效果很好.

I've got a form that I clear on focus. I've selected the whole form and it works great except that the submit button goes blank when I click it.

如何从以下代码中排除输入#submit的输入?

how can I exclude my input of input#submit from the following code?

    $(".wpcf7-form input, .wpcf7-form textarea").focus(function() {
 if( this.value == this.defaultValue ) {
  this.value = "";
  $(this).addClass('filled');
 }
}).blur(function() {
 if( !this.value.length ) {
  this.value = this.defaultValue;
  $(this).removeClass('filled');
 }
});

推荐答案

使用

Use the not selector to exclude what you want:

$(".wpcf7-form input:not('#submit_id'), .wpcf7-form textarea").focus(function() {
 // your code......
}

$(".wpcf7-form input:not(input[type=submit]), .wpcf7-form textarea").focus(function() {
 // your code......
}

这篇关于jQuery排除选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆