好什麼我試圖做的是切換3個密碼輸入框與一個複選框...點擊複選框我想所有3密碼顯示在那裏輸入框。無論如何要適應這個?用單個複選框切換多個密碼輸入
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
Created using jsbin.com
Source can be edited via http://jsbin.com/opafo3/1/edit
-->
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>Sandbox</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
body { background-color: #000; font: 16px Helvetica, Arial; color: #fff; }
</style>
<style id="jsbin-css">
</style>
</head>
<body>
<p><input id="show" type="checkbox" /><label for="show">show password</label></p>
<p><input id="txtpassword" type="password" /></p>
<script>
$(function(){
$("#show").click(function(){
if($("#show:checked").length > 0){
var pswd = $("#txtpassword").val();
$("#txtpassword").attr("id","txtpassword2");
$("#txtpassword2").after($("<input id='txtpassword' type='text'>"));
$("#txtpassword2").remove();
$("#txtpassword").val(pswd);
}
else{
var pswd = $("#txtpassword").val();
$("#txtpassword").attr("id","txtpassword2");
$("#txtpassword2").after($("<input id='txtpassword' type='password'>"));
$("#txtpassword2").remove();
$("#txtpassword").val(pswd);
}
});
})
</script>
</body>
</html>
我已經嘗試了幾件事情,但我無處可去。