Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Exclude a Selector?

Tags:

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.

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');
 }
});
like image 909
wesbos Avatar asked Jun 08 '10 21:06

wesbos


Video Answer


1 Answers

Use the not selector to exclude what you want:

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

Or

$(".wpcf7-form input:not(input[type=submit]), .wpcf7-form textarea").focus(function() {
 // your code......
}
like image 81
Sarfraz Avatar answered Jan 01 '23 09:01

Sarfraz