0
function close_w() {
//close the window
}
function imgopen(image) {
var newWindow=window.open("", "_blank", "width=450, height=400");
var newButton=newWindow.document.createElement("button");
var textNode=newWindow.document.createTextNode("Close");
newButton.setAttribute("style", "text-align: center; width: 30%; height: 30px; margin-top: 10px; margin-left: 35%; border: none; color: #FFF; background-color: #DC143C");
newButton.setAttribute("onclick", "close_w()");
newWindow.document.newButton.appendChild(textNode); // Line Marker
newWindow.document.body.appendChild(newButton);
}
我想將一個按鈕放在彈出窗口中,但將textNode附加到newButton不起作用,甚至按鈕不顯示。如果我刪除標記的行,只顯示按鈕。關閉窗口並將文本節點追加到按鈕
而且我還想讓按鈕被點擊時彈出關閉,但我無法想象如何做到這一點。我可以使用什麼函數來做close_W()?
這是一種任務:我不能在這裏使用jQuery。
我對JS很虛弱。請幫忙!
我在這裏看到一些答案,說文本節點並將其附加到按鈕將工作。有沒有辦法使用這種方式?我知道innerhtml會工作,但只是好奇。 – keist99
我不知道如何能夠使用文本節點並將其附加到按鈕。向文本添加文本時,最好使用文本節點,例如'
',但我從未嘗試在按鈕上使用它。這可能是可能的,但我不知道你是如何做到的,但我仍然不會提出。 – CyanCoding