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

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -