开发者

how to make javascript class derived from jquery object?

开发者 https://www.devze.com 2023-02-27 05:48 出处:网络
I want to make a constructor whose instances are jquery objects, so that var obj = new MyConstructor();

I want to make a constructor whose instances are jquery objects, so that

var obj = new MyConstructor();
$("body").appen开发者_如何学Pythond(obj); // append instance to html body

how do implement such a constructor ?


A jQuery object is just a DOM element which has been augmented (by jQuery). What is insufficient about this? Unless you have some other use case in mind, you don't need to do anything fancy with a constructor.

var $obj = $('<div>Foo bar baz</div>');
$('body').append($obj);

// really, all you need is this:
$('body').append('<div>Foo bar baz</div>');
0

精彩评论

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