获取同级 HTML 元素的标签?(jQuery)

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

本文关键字:jQuery 标签 HTML 元素 获取      更新时间:2023-09-26

目前,我有以下内容:

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

我正在使用 EXT.NET 它形成元素的方式真的很古怪。无论如何,我需要的是找到HTML中下一个元素的标签。里面的代码看起来像这样:

  <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>

当我尝试使用alert($(this).next().attr("tagName"))时;它返回"unidentity"

从jQuery 1.6开始使用.prop("tagName");