Javascript personalized function -
i need know how make jquery
function
, not css selectors, this:
function getid( item ) { return document.getelementbyid( item ); } getid('elementid').firstfunction('property').secondfunction('property');
but don't know how send getid
result firstfunction
make getid()
element , make secondfunction
work, i've been trying prototype
can't make work.
you need ensure of methods want able chain accept same context output, in case dom element.
so, firstfunction
, secondfunction
should both expect this
dom element , should return dom element well. means, however, need modify built in dom element object , add own methods, generally bad idea. why jquery wraps in wrapper object contains methods available api. methods act on this
(which must of same special object type) , return (usually modified) object of same type.
check out lighter-weight example here: http://buildingwebapps.blogspot.com/2012/01/creating-lightweight-dom-javascript.html , additional reading here: http://kendsnyder.com/posts/element-wrappers-in-javascript
Comments
Post a Comment