Reputation: 1614
It's a quick question for you,
I need to select Jquery element by type AND by name.
I know that we can do something like:
$('.form-control input[type=text]')....
but I need to select by name too..
do you have another way to do that unless using:
$('.form-control input[type=text]').each(function (){
if($(this).attr('name') == 'search'){
// this is my selector
}
}
thank you
Upvotes: 2
Views: 123
Reputation: 6131
$('.form-control input[type=\'text\']')
or by name you can go
$('.form-control input[name=\'search\']')
Upvotes: 0
Reputation: 82251
use:
$('.form-control input[type=text][name="search"]').each(function (){
//ohh yeah....this is my selector
}
Upvotes: 0
Reputation: 133453
You should use Multiple Attribute Selector [name="value"][name2="value2"]
$('.form-control input[type=text][name="search"]')
Upvotes: 4