2013-11-25 43 views
0

我想將我的文字標籤在自定義位置使用document.style.position我有這樣的腳本:如何更改項目的位置槽style.position?

var clickHandler = function() { 
    var doc = document.getElementById("result"); 
    doc.style.visibility = "visible"; 
    doc.style.color = "#ff0000"; 
    doc.style.position = "left:150px"; 
} 

(見於this的位置教程)。我錯在哪裏?

+1

應該'doc.style.left = 「150像素」''position'是「絕對/相對」等 – PSL

+0

CSS位置:https://developer.mozilla.org/en-US/docs/Web/CSS/position – epascarello

回答

4

檢查這個代碼:

var clickHandler = function() { 
    var doc = document.getElementById("result"); 
    doc.style.visibility = "visible"; 
    doc.style.color = "#ff0000"; 
    doc.style.left= "150px"; 
}