I am trying to change the position and style of a dynamically added element, but my changes are not taking affect. Any ideas why?
I appreciate your assistance.
function addButtons()
{
var button1 = document.createElement('button');
button1.innerHTML = 'Relevant';
button1.onclick = function()
{
alert('test');
return false;
};
document.getElementsByClassName('subject')[0].appendChild(button1).style.left="6000px";
};
如果元素不具有position: absolute
, position: fixed
或position: relative
,则作为内联样式或从样式表继承, left
均无效
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.