Reputation: 11
I need to use find() to find all inputs in a form and change its value to ''. But I also need to exclude 2 inputs, the name of these inputs are: 'data', and 'date'
I tried this (with no success)
$('#contactForm').find("input[ @name != 'data' ][ @name != 'date' ]").val('');
Upvotes: 1
Views: 97
Reputation: 163288
Use jQuery
's not
method:
$('#contactForm').find('input').not("[name='data'],[name='date']").val('');
Here's a jsFiddle example.
Upvotes: 2
Reputation: 5358
$('input').each(function(){
if ( this.name != 'data' && this.name != 'date')
this.value = '';
});
Upvotes: 0