I need to detect whether it's a <option>
or something else
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Try this:
Since a jQuery object is an array of objects you can retrieve the underlying DOM element by indexing that array. Once you have the element you can retrieve its
tagName
. (Note that even if you have one element you will still have an array, albeit an array of one element).You should be able to check the
.nodeName
property of the element. Something about like this should work for you:I generally prefer using jQuery's
.is()
to test what something is.You can use the
is
method to check whether a jQuery object matches a selector.For example: