tags:

views:

53

answers:

3

I like to select an element by more than two condition.

for example

name is some name and checked

how can I do this?

+2  A: 

You can append the attribute and :checked selectors, like this:

$("[name=myName]:checked")

Th key here, don't leave a space and you're telling Sizzle (jQuery's selector engine) to filter on the same element. If you put a space between, it's would be: "find checked children of elements with this name."

Nick Craver
A: 

You can do like this:

if ($('input[name="some_name"]').is(':checked'))
{
  // your code here...........
}

This makes sure that it checks only for form input which is exactly what you are looking for.

Sarfraz
A: 

jQuery uses CSS Selector rules for document matchings. if you know how to use CSS Selectors you will know how to do this use this as reference http://api.jquery.com/category/selectors/

and read more about CSS Selectors

Kronass
While this is partially true, jQuery implements CSS selectors *and* some others, for example `:animated` isn't in CSS :)
Nick Craver
I didn't mention it in the post because it was already written in the link that I provided. any how thanks for your notice I will include more accurate information in my next posts
Kronass