Select SELECT field with jquery

Asked

Viewed 289 times

1

I’m using the remote

.find(input[type='text'],input[type='url'],input[type='radio']) , to find form fields in a form.

would like to search for fields <select>

What notation do I use in .find() to also search for fields of the type <select>?

3 answers

1

Add select ai to the list

$.find("input[type='text'],input[type='url'],input[type='radio'], select")

0

To search for a DOM tag via jQuery you just need to add the name of the jQuery search tag. Example:

$('select').each(function(index, item) {
  alert($(this).find('option').length);
});

the above code will give an alert with the amount of option of each select in the GIFT

  • the whole question that when I search, I want to search form fields, example I put, searched input fields of different types. I need to know the jquery notation for <select field search> .

0

Primarily you should add the select to the list, which will get it picked up together, as stated in a previous reply.

the main selectors in jquery are:

$('elemento') to select all elemenentos of a type

$('.classe') to select all elemenentos with a class

$('#id') to select the element with that id (or the first with that id in the DOM)

if you want to know more about jquery selectors follow a link with more explanations

Browser other questions tagged

You are not signed in. Login or sign up in order to post.