Serguei Fedorov
Serguei Fedorov

Reputation: 7943

Get the Tag of the sibling HTML element? (jQuery)

Currently, I have the following:

                    if ($(this).next().attr("tagName") == "INPUT") {
                        increment += 20;
                    }

I am using EXT.NET which is really wacky in the way it does form elements. Anyways, what I need is to find the tag of the next element in the HTML. The code inside looks as such:

  <div class="x-form-field-wrap x-form-field-trigger-wrap" id="ext-gen80" style="width:    167px; ">
  <input type="hidden" name="ctl00_MainContent_Department_Value" id="ext-gen82" value="" style="border-bottom-width: 2px; border-bottom-color: rgb(87, 196, 255); ">
  <input type="text" size="24" autocomplete="off" id="ctl00_MainContent_Department" name="ctl00_MainContent_Department" class="x-form-text x-form-field" style="width: 142px; border-bottom-width: 2px; border-bottom-color: rgb(252, 164, 76); ">
  <img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-form-trigger x-form-arrow-trigger" id="ext-gen81" style="">
  <input type="hidden" size="20" autocomplete="off" id="ctl00_MainContent_Department_SelIndex" name="ctl00_MainContent_Department_SelIndex" class=" x-form-hidden x-form-field" style="border-bottom-width: 2px; border-bottom-color: rgb(87, 196, 255); "></div>

when I try and use alert($(this).next().attr("tagName")); it returns "unidentified"

Upvotes: 0

Views: 528

Answers (1)

Jeff Watkins
Jeff Watkins

Reputation: 6357

use .prop("tagName"); as of jQuery 1.6.

Upvotes: 1

Related Questions