我想用下面的代碼隱藏我的表單中的輸入元素。但它不起作用...如何隱藏表單中的所有輸入元素?
<html lang="en">
<head>
<title>children demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<h1>Hello</h1>
<div>
<h1 class="selected">div-1</h1>
<h1 class="selected">div-2</h1>
</div>
<h1>xyz</h1>
<form name= "demo form">
First name:<input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="submit">
<script>
$("div").children(".selected").css("background-color", "yellow");
document.body.style.backgroundColor = "red";
$(demo_form.elements).hide();
</script>
</body>
</html>
$( '輸入')隱藏(); – guradio
你錯過了jquery選擇器中的'''' –