There are a bunch codes that uses this syntax.
I'm wondering how to do that?
- Code:
[panda=js]functionName( {hey: [hello, hi]; } );
I'm wondering how to do that?
[panda=js]functionName( {hey: [hello, hi]; } );
[panda=js]function create(type, options)
{
var element = document.createElement(type);
if(typeof options !== "object")
return element;
for(var properties in options)
{
if(properties in element)
{
element[properties] = options[properties];
}
else
{
element.setAttribute("data-"+properties,options[properties]);
}
}
return element;
}
//use case
var newDiv = create("div",{
id:"newDiv",
className:"google newdivclass",
attr:"hitsu",
innerHTML:"Hello World"
});
//this returns the below html
[panda=html]<div id="newDiv" class="google newdivclass" data-attr="hitsu">Hello World</div>
|
|