通过JS动态创建一个html DOM元素并显示(2)
使用示例: var htmlAttributes= [{attrName:'class',attrValue:'样式名称'} //for IEs,{attrName:'className',attrValue: '样式名称'} //for ff] var domParams={domTag:'div', content:'动态div的
使用示例:
var htmlAttributes= [ {attrName:'class',attrValue:'样式名称'} //for IEs , {attrName:'className',attrValue: '样式名称'} //for ff ] var domParams={domTag:'div', content:'动态div的innerHTML', otherAttributes:htmlAttributes}; var newHtmlDom=dynCreateDomObject(domParams); //通过setAttribute('style','position:absolute.....................') //的形式来指定style没有效果,只能通过如下形式,jiong newHtmlDom.style.zIndex='8888'; newHtmlDom.style.position='absolute'; newHtmlDom.style.left='100px'; newHtmlDom.style.top='200px';
收藏文章
精彩图集
精彩文章