我在jQuery中使用.show
和.hide
时遇到问题。基本上我想要一旦你点击注册按钮就出现两个选项,这就是代码:
HTML
<div id='register'>
<form>
<input type='button' class='register-button' name='register-button' value='R e g i s t e r !'>
</form>
<form id='register-type'>
<span class='register-type-background'> </span>
<input type='button' class='register-type-band' name='register-type-band' value='Band'>
<input type='button' class='register-type-user' name='register-type-user' value='User'>
</form>
</div>
JQuery的:
$(document).ready(function(){
$('#register-type').hide();
$('.register-button').click(function(){
$('#register-type').show();
});
});
更多HTML:
<head>
<title> Title </title>
<link rel='stylesheet' href='stylesheet.css' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
<script type='script' src='javascript.js'> </script>
</head>
答案 0 :(得分:2)
您的代码为fine as it is,但问题是您的实际script
参考:
<script type='script' src='javascript.js'> </script>
没有type='script
,需要type='text/javascript'
,将其更改为:
<script type='text/javascript' src='javascript.js'> </script>