var xmlns = "http://www.w3.org/2000/svg";
var play = document.createElementNS(xmlns, "svg");
play.setAttribute("width", "20");
play.setAttribute("height", "20");
var pause = document.createElementNS(xmlns, "svg");
pause.setAttribute("width", "15");
pause.setAttribute("height", "20");
var stop = document.createElementNS(xmlns, "svg");
stop.setAttribute("width", "20");
stop.setAttribute("height", "20");
function playButton() {
var polygon = document.createElementNS(xmlns, "polygon");
polygon.setAttribute("points", "0,0 0,20 20,10");
polygon.setAttribute("fill", "green");
play.appendChild(polygon);
document.body.appendChild(play);
}
playButton();
function pauseButton() {
var path = document.createElementNS(xmlns, "path");
path.setAttribute("d", "M0,0 L0,20 L5,20 L5,0 L0,0 M10,0 L10,20 L15,20 L15,0, L10,0");
path.setAttribute("fill", "green");
pause.appendChild(path);
document.body.appendChild(pause);
}
pauseButton();
function stopButton() {
var rect = document.createElementNS(xmlns, "rect");
rect.setAttribute("width", "20");
rect.setAttribute("height", "20");
rect.setAttribute("fill", "red");
stop.appendChild(rect);
document.body.appendChild(stop);
}
stopButton();
svg {
margin: 3px;
}
@ chipChololate.py我beleive的第三代碼段已被添加到HTML?我們可以在不修改html的情況下做到這一點嗎? – Siva 2014-11-21 10:42:02
當然!讓我編輯它。 – 2014-11-21 10:42:53