My code is like so
function show_file(itemid) { document.getElementById("itemid").innerHTML = "Testing"; }
<td id='$itemid' class='header-row'> MyText quote <button onclick='show_file($itemid)'> Button<i class='fa fa-angle-down'></i> </button> </td>
But I get this error "Cannot set property 'innerHTML' of null" so it seems the value of $itemid is not getting passed?
You should pass the actual function's parameter itemid
not the string "itemid"
Change it from:
function show_file(itemid) {
document.getElementById("itemid").innerHTML = "Testing";
}
To:
function show_file(itemid) {
document.getElementById(itemid).innerHTML = "Testing";
}
That is because you gived a string in parameter to your getElementById function and not the itemid variable. Try this :
function show_file(itemid) {
document.getElementById(itemid).innerHTML = "Testing";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.