Problem with not() selector in IE8
I'm having problems with the following line of jQuery code
var controls = selectedForm.find('input:not(type="hidden"), checkbox, select, textarea');
What I'm trying to do is to select al开发者_StackOverflowl the elements in selectedForm that are not <input type='hidden'....>
. selectedForm is a previous selector that selects the form object of interest. There a total of 5 fields inside this form, one of which is the hidden input field.
My problem is that in IE8, the variable "control" contains all 5 fields inside the form. In FF6, this works correctly and returns the 4 fields I'm interested in.
I'm assuming that I have a syntax error, but I cannot see what it is.
Note you are trying to use an attribute equals selector for the attribute "type" which should be enclosed with brackets:
var controls = selectedForm.find('input:not([type="hidden"]), checkbox, select, textarea');
John Hartsock correctly identified the problem there (must use [type="hidden"]
), however you can also write that query without using the :not
selector:
selectedForm.find('input[type!="hidden"], checkbox, etc');
http://api.jquery.com/attribute-not-equal-selector/
精彩评论