There is no problem with writing the code, why can't it run!


< html >
< head >
< title > example < / title >

< script >

var toggleHidden=function () {

var elem= document.getElementById("toggle");
if(elem.hasAttribute("hidden")){
  elem.removeAttribute("hidden")
}else{
   elem.setAttribute("hidden","hidden");
}

}
< / script >
< / head >
< body >

<button onclick="toggleHidden()">toggle</button>
<table>
<tr><th>Name</th> <th>City</th></tr>
<tr id="toggle" hidden=""><td>Kevin</td><td>Shijiazhuang</td></tr>
<tr><td>Kevin</td><td>Shijiazhuang</td></tr>



</table>

< / body >

< / html >

Mar.11,2021

document and getElementById are misspelled, and onclick= "toggleHidden ()" says


first of all, it should be written in parentheses

<button onclick="toggleHidden()">toggle</button>

is followed by spelling mistakes, and the correct code is as follows

var elem = document.getElementById('toggle');

1.
2, < button onclick= "toggleHidden ()" > toggle < / button >
3, var elem= documet.getElementById ('toggle'); document?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b351a1-2b6e4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b351a1-2b6e4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?