JS orang baru, sila beritahu saya mengapa kaedah penulisan 1 tidak dilaksanakan apabila kaedah penulisan 1 ditukar kepada borang lulus parameter? Terima kasih!
<html>
<form id="search-bar" class="hide" action="/action_page.php">
<input id="search-box" type="search" value="search">
<input id="search-submit" type="submit">
</form>
<button id="search-but" >click me</button>
</html>
Kaedah penulisan 1:
<skrip>
var osearch = document.getElementById("search-but")
var obar = document.getElementById("search-bar")
osearch.onclick = function () {
if (obar.style.display == "block") {
obar.style.display ="none"
}
else {
obar.style.display="block"
}
}
</skrip>
Kaedah penulisan 2:
<skrip>
function display(obj) {
var b = document.getElementById("obj")
if (b.style.display == "block") {
b.style.display = "none"
}
else {
b.style.display = "block"
}
}
var osearch = document.getElementById("search-but")
osearch.onclick=display(search-bar);
</skrip>
Foundation tak kukuh