tags:

views:

36

answers:

3

This works in jQuery 1.3.2, but not in 1.4

$("#container").children().map(function() {
    var child = $(this);

    if (child.is(":select")) {
        //do something with child
    }
});

What is the right way to do this in jQuery 1.4?

A: 

If I understand you correctly, I would suggest accessing the tagName (tested):

$("#container").children().map(function() {
    var child = $(this);

    if (child[0].tagName == "SELECT") { // or this.tagName == "SELECT"
        //do something with child
    }
});
karim79
A: 

it should be ":selected" if you want to figure whether a checkbox is checked or not.

if you want to figure out what kind of element you're dealing with, go with the answer below using nodeName or tagName.

Kind Regards --Andy

jAndy
A: 

If you want select elements:

$("#container").children().map(function() {
    var child = $(this);

    if (child.is("select")) {
        //do something with child
    }
});

children() does accept a selector, so you can cut this down to:

$("#container").children('select').map(function() {
    var child = $(this);
    //do something with child
});
Matt
Thanks, still can't believe that : was the big deal :)
Vnuk