2009-07-14 93 views
-6

我有4複選框,當我選擇任何一個複選框需要顯示相應的複選框和文本框。Jquery - 複選框和多個文本框

INPUT TYPE = 「複選框」 ID = 「A檢查[]」 值= '名稱'

INPUT TYPE = 「文本」 ID = 「productfield」 值=」'

jQuery代碼:

$(document).ready(function() { 


     $("#productfield").css("display","none"); 

     $("#acheck").click(function(){ 

       if ($("#acheck").is(":checked")) 
       { 

        $("#productfield").fadeIn("slow"); 
       } 
       else 
       {  

        $("#productfield").fadeOut("slow"); 
       }  

     }); 

}); 
+3

你應該更清楚自己真正想要做的 – jitter 2009-07-14 11:42:43

回答

1

這個問題並不清楚,但我想你想在點擊複選框時顯示一些內容?這應該讓你開始。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <style> 
    #appear_div { display: none; } 
    </style> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
    <script> 
    $(document).ready(function() { 
     $('#appear').click(function() { $('#appear_div').show(); }); 
    }); 
    </script> 
</head> 
<body> 
    <input type="checkbox" id="appear"> 
    <div id="appear_div"> 
    <input type="checkbox" id="cb1">Check me <input type="text" id="text1"> 
    </div> 
</body> 
</html>