开发者

Get the ID of node using YUI 3.3

开发者 https://www.devze.com 2023-03-30 13:51 出处:网络
There is one accordian in YUI and I want element id of the element which height is more than 0px. Here is some part of code

There is one accordian in YUI and I want element id of the element which height is more than 0px.

Here is some part of code

<div class="accordian">
 <div id="item1" class="yui3-widget-bd"></div>
 <div id="item2" class="yui3-widget-bd"></div>
</div>

and javaScript

YUI().use("node", function(Y) {
    Y.all('.yui3-widget-bd').each(function(node) {

        accHeight = node.get("offsetHeight");
        alert("this is height " + accHeight);

        if (accHeight > 0) {
            alert("insid开发者_JAVA百科e if");
            alert(node.get("ID"));

        }
        else {
            alert("in else condition");
        }

    });

})

Instead of getting "Item1 " alert. I am getting "undefined"

Working example on JSFiddle


It is case sensitive. id should be lower case.

node.get("id")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号