简体   繁体   English

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

[英]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. 我使用的是EXT.NET,它的形式元素确实很古怪。 Anyways, what I need is to find the tag of the next element in the HTML. 无论如何,我需要在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")); 当我尝试使用alert($(this).next()。attr(“ tagName”)); it returns "unidentified" 它返回“ unidentified”

use .prop("tagName"); 使用.prop("tagName"); as of jQuery 1.6. 从jQuery 1.6开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM