-4
這很傷心因爲這應該是非常簡單的,但由於某種原因,它不工作。 我試圖讓這個是打字的快捷方式在Idk如何解決這個錯誤,我有
document.getElementById("id").innerHTML
但是當我運行程序時,它不會做任何事情。
這裏是我的代碼:
function writeTo(text,loc,method){
var location = document.getElementById(loc);
if(method == "rep")
location.innerHTML = text;
if(method == "add")
location.innerHTML += text;
else
alert("Error: Unknown method \""+method+"\". Use \"rep\" to replace or \"add\" to add.");
}
這裏的輸出區域:
<p id="test">This is text!</p>
,並在這裏就是我所說的:
writeTo("Text","test","rep");
看起來很好,但是你希望第二個if如果是else if。 http://jsbin.com/tekaji/1/ – 2014-10-09 00:55:17
OMG PEOPLE!如果你不能解決問題,請不要付款! – erMahGerdSlenderphobia 2014-10-09 00:55:42
我改變了它,如果它仍然沒有做任何事情。 – erMahGerdSlenderphobia 2014-10-09 00:57:54