Reputation: 28755
I am using a JQuery Plugin, which uses following line
var inputSelector = 'input[class]:not(:button|:submit|:reset), textarea[class], select[class]';
It select some element.
It also selects the hidden element, how can I achieve that without giving any class to hidden element?
And It must work in IE.
Upvotes: 4
Views: 2257
Reputation: 17640
took me a minute but figured it out jsfiddle example
sorry it didn't save right
EDIT now with no class
here is the html
<input type="text" name="foo" />
<input type="hidden" name="hidden" id="bar" value="surprise" />
<input type="submit" name="submit" />
here is the jQuery
var inputSelector = 'input:not(:button, :submit, :reset,:hidden), textarea, select';
$(inputSelector).val('foobar');
var bc = $('#bar').val();
alert(bc);
The alert should say "surprise" because the hidden element with id "bar" is not selected
Upvotes: 1
Reputation: 13230
You could use the not() method on the array returned by the selector.
var inputSelector = 'input[class]:not(:button|:submit|:reset), textarea[class], select[class]';
var controls = $(inputSelector).not('[type="hidden"]');
This filters the hidden elements out of the array returned by the selector.
Upvotes: 2
Reputation: 12320
var inputSelector = 'input[class]:not(:button|:submit|:reset|:hidden), textarea[class], select[class]';
Will not select hidden elements as well.
Upvotes: 0