Jwee API > Wee.elem - Element Functionswee.elem create(...)
create? create(...) create(...) createFromHTML(...) addMethods(...) absoluteCenter() The wee.elem toolkit contains just a couple functions doing with elements. Most importantly, it provides a function to easily create new elements. function wee.elem.create(...)( string tag, [object attributes] , [string css] , [element parent] )
This is how you can create new HTML elements from code. Make a new <DIV>. wee.elem.create( "div" ); Make a new <DIV> with a #id. wee.elem.create( "div#pageheader" ); Make a new <DIV> of a particular CSS class. wee.elem.create( "div.bigblueboxr" ); Make a new <DIV> element that has a blue border. wee.elem.create( "div", "border:1px solid blue" ); Make a new <DIV> element, and add it to the page, on <BODY>. wee.elem.create( "div", Dom.body() ); // OR LIKE Dom.body().append( wee.elem.create( "div" ) ) Make a new <INPUT> element that is a text box and with name of login. wee.elem.create( "input", {name:"login", type:"text"} ); Make a new <INPUT> element that is a text box and with name of login, and has font-size of 20px. wee.elem.create( "input", {name:"login", type:"text"}, "font-size:20px;" ); Make a new <INPUT> element that is a text box and with name of login, and add it to a form on the page. wee.elem.create( "input", {name:"login", type:"text"}, document.forms["loginForm"] ); // OR LIKE THIS wee.elem.create( "input", {name:"login", type:"text"}).appendTo( $("loginForm") ); ??? create?
Blah blah function wee.elem.create(...)( element elementToCopy )
There are many more examples, but this is a start. wee.elem.create(...) aims to provide you shortcuts for common things. function wee.elem.create(...)( string html, [parent / attributes / css . . . ] )
Creating a new HTML element from raw HTML can be easier sometimes. The code below demonstrates that, and then appends the new DIV to the end of the BODY Elem.create('< div id="myDiv" style="background:black;">My New DIV< /div >', Dom.body() ); function wee.elem.createFromHTML(...)( string html )
function wee.elem.addMethods(...)( object methods )
function wee.elem.absoluteCenter()
|