开发者

How to get javascript control from JQuery object?

I'm a 开发者_C百科beginner in JQuery,

How can I get the control as a javascript object from a JQuery object

var _object = $(this). ??


Most common var _object = $(this)[0];

If you have more than 1 elements matched: $(this)[0], $(this)[1], $(this)[2] and so on.

$(this).get() is also possible. It's only advantage over the array model is that it allows selection of the kind $(this).get(-1) where it gets you the last matched object


var _object = $(this)[0];

I think this is right, can't check though because I'm on my phone.


In your case, simply use this.

$(this)[0] == this if this is a DOM element. If it's something else, e.g. a selector, $(this)[0] is the way to go.


(function (e) {
    var a = false;
    try {
        $(this)[0];
        a = true;
    } catch (h) {}
    alert(a.toString());
})(window);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜