这让我有点抓狂。 Javascript 链接应该触发函数来填充 div。但不起作用。
js
function showNotes(notes,id) {
var notes = '<form action="editnotes.php" method="post"><textarea>'+notes+'</textarea><input type="hidden" name="id" value="'+id+'"><input type="submit" name="submit" value="Save Notes"></form>';
var target = 'notebox';
alert(id);
document.getElementById(target).innerHTML = notes;
return false;
}
html
<a href='#' onclick='showNotes('hi there','143');'><small>Show Notes</small></a>
<div id="notebox"></div>
最佳答案
将 onclick
属性值括在双引号中,以便单引号指定字符串中的字符串。
onclick="showNotes('hi there','143');"
关于JavaScript 链接不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11025232/