使用闭包实现显示隐藏div

<div class="binds">
		<div class="phonebind">
			<h3>手机绑定</h3>
			<p>当前手机号码:<span id="oldPhone">$!{user.phone}</span><input type="button" class="btnInput" id="rebindPhone" value="重新绑定"></p>
			<div class="updatetelwrap  hidden">
				<div class="newphonewrap">
					<label>新手机号码<em>*</em></label>
					<input type="text" class="formatText" id="newPhone" />
				</div>
				<div class="identifywrap">
					<label>短信验证码<em>*</em></label>
					<input type="text" class="inputcode" />
					<input type="button" value="获取短信验证码" class="identifycode"/>
					<p><input type="button" value="绑定" class="bindbtn" id="newphonebind" style="float: left;" onclick="javascript:bindPhone();" /></p>
				</div>
			</div>
		</div>
		<div class="emailbind">
			<h3>邮箱绑定</h3>
			<p>当前电子邮箱:<span id="oldEmail">$!{user.email}</span><input type="button" class="btnInput" value="重新绑定" id="rebindEmail"></p>
			<div class="update-email-wrap hidden">
				<div class="emailwrap">
					<label>新电子邮箱<em>*</em></label>
					<input type="text" class="formatText" id="newEmail" />
					<p><input type="button" value="发送验证邮件" id="sendEmail" style="float: left;" class="btnInput" onclick="javascript:bindEmail();"  /></p>
				</div>
			</div>
		</div>
	</div>
<script>
	$(function(){
		$(document).on("click","#rebindPhone",bindInputclick());
		$(document).on("click","#rebindEmail",bindInputclick());
	})
	function bindInputclick(){
		var i=2;
		return function(){
					if(i%2==0){
						$(this).parent().next().slideDown();
					}
					else {
						$(this).parent().next().slideUp();
					}
					i++;
		}
	}
</script>

你可能感兴趣的:(使用闭包实现显示隐藏div)