这是我的代码片段jsfiddle。为什么我的onclick事件不起作用?
我想要“+创建论坛”按钮来显示窗体,“取消”按钮来重置窗体并隐藏它,如果您想查看窗体,请删除“style =”display:none“
我用了很多例子了W3Schools的和我曾尝试使用写节目的所有实例和隐藏,工作的复位之一,但它是一个的onclick =“this.reset()”,这是不我想要的东西,因为我想它隐藏了。
<html>
<body>
<button class="btn btn-default" type="submit" id="createform">+ Create Forum</button>
<div class="form-group" id="createForum">
<form action="forums.php" method="get" id="forumForm" style="display: none">
<label>Forum name:</label>
<input type="text" class="form-control" id="forumName">
<label>Description:</label>
<textarea class="form-control" rows="5" id="description"></textarea>
<button class="btn btn-danger" type="submit" name="create">Crear</button>
<input type="button" value="Reset Form" onclick="clearing()">
</form>
</div>
</body>
<script type="text/javascript">
$("#createform").click(function() {
$("#forumForm").show();
});
function clearing() {
document.getElementById("forumForm").reset();
}
</script>
您正在使用jquery和香草javascript的混合。此外,我会建议不内嵌JavaScript像你有输入onclick方法“清除” – Enjayy