Thanks for this too. I was looking for the documentation for .is the other day and couldn't find it.
On Mar 25, 12:26 pm, jerone <jeron...@gmail.com> wrote: > You can do: > $("input#foo") > $("span#foo") > > or you can use the "is" function:http://docs.jquery.com/Traversing/is#expr > if($("#foo").is("span")){ > // code > }else if($("#foo").is("input")){ > // code > } > > On 25 mrt, 19:15, Brad <nrmlcrpt...@gmail.com> wrote: > > > I'm working on a page that dynamically changes many form elements. > > Because of the way that different browsers style disabled or readonly > > text inputs, I'm swapping the input with a span that displays more > > consistently. I don't need to submit those fields. However, when I do > > this the affected element's ID does not change. There are also some > > other cases where a control may change from a free text input to a > > select menu and vice versa, but again with the same ID. > > > If there a way for me to figure out what the type of element for a > > matched ID? For example if > > > $("#foo") > > > matches > > > <input id="foo" ...> > > > I'd like to know it is an input, but if > > > $("#foo") > > > matches > > > <span id="foo" ...> > > > I'd like to know it is a span?