I have a field with input type search
When I try to select that with jQuery I get VM535 jquery-git.js:1529 Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: search
Check the fiddle - Fiddle
How do I select that field? (note: I do not have any unique class or id applied to that field, actually it's plugin generated.)
Actually I am using jQuery DataTable
plugin and I want to add a Go button just besides the search box. For this I am trying this workaround - to select the
search box with jQuery and add button besides it with insertAfter
method. Please suggest me if there is any other way for this.
You can use attribute selector in such cases. Try this:
alert($('input[type="search"]').val());
Working example here: https://jsfiddle.net/ashishanexpert/dsye8b2x/1/
input:search
is not a validselector(not listed in Selectors section in the docs)
Use Attribute Equals Selector input[type="search"]
alert($('input:text').val());
alert($('input[type="search"]').val())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<input type="text" value="text">
<br/>
<input type="search" value="search">
<br/>
you were close, do this: alert($('input[type="search"]').val())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With