Hello there,

i have a couple of elements on my web page, that i want to manipulate
in one loop.

jQuery.each($(".specificClass"), function(i) {
    // do something
}

Within that loop i have to check what type of element that very one is
e.g. a <div> or a <span> or an <img> or a <input type="button"> or
something else.

I managed to isolate some of them, the easiest was the button where i
checked the following:

if ($("selector").is(":button")) {
    // do something
}

In the jQuery API 1.3.2 there are some more useful Forms Filters
like :input, :text, :checkbox etc.

What i really miss is something for a drop down list.
I would have expected that there is something like

if ($("selector").is(":select")) {
    // do something
}

but i could not find it.

It would also be great to have something to check if the element is an
image. I have read that there exist such a check, but that is for
images that are input-images within a form. I am longing for a simple
check for an image somewhere in the web page.

At the moment i build workarounds like this, but that is not really
satisfying...

if ( !isNullOrEmpty($("selector").attr("src"))) { // --- image ---
        // do something
}
if ($("selector")[0].selectedIndex >= 0) { // --- drop down list ---
        // do something
}

// convenience function like the one in C#
window.isNullOrEmpty = function(obj) {
        return (obj === '' || obj === null || obj === undefined)
}

Reply via email to