2012-03-16 67 views
1

隨着成功我創建了一個頁面,它使用了一組單選按鈕,它們是格式化的jquery。但是,只要我添加div來定位頁面上的內容,單選按鈕仍然是格式化的,但不再作爲單選按鈕(它們就像複選框一樣)。這是我的代碼,它有什麼問題?添加div後,Buttonset不再工作

<script> 

    $(document).ready(function() { 

    $("#dt_hel").buttonset(); 

    }); 

</script> 

<!-- end script radiobuttons -->   

<div class="demo"> 
<div id="ContentContainerLeft" > 
<form id="dt_this_form" name="dt_this_form" action="this.php" method="post"> 
<p> 
</div> 
<div id="ContentContainerMiddle" > 
<P> 
<div id="dt_hel" style="font-size:80%;"> 
    <input type="radio" id="radio1" name="dt_hel" value="0" /><label for="radio1">Lower</label> 
    <input type="radio" id="radio2" name="dt_hel" value="1" /><label for="radio2">Equal</label> 
    <input type="radio" id="radio3" name="dt_hel" value="2" checked/><label for="radio3">Higher</label> 
</div> 
<P></P> 
</div> 
<div id="TweetContainer" > 
<P> 
</div> <!-- end tweetcontainer --> 
</div><!-- End demo --> 
</form> 

回答

1

如果你遵循關閉舊標籤之前關閉最近的標籤(即設置的形式打開標籤之上的標籤)的規則,那麼它應該工作如

<form id="dt_this_form" name="dt_this_form" action="this.php" method="post"> 
<div class="demo"> 
<div id="ContentContainerLeft" > 

<p> 
</div> 
<div id="ContentContainerMiddle" > 
<P> 
<div id="dt_hel" style="font-size:80%;"> 
    <input type="radio" id="radio1" name="dt_hel" value="0" /><label for="radio1">Lower</label> 
    <input type="radio" id="radio2" name="dt_hel" value="1" /><label for="radio2">Equal</label> 
    <input type="radio" id="radio3" name="dt_hel" value="2" checked/><label for="radio3">Higher</label> 
</div> 
<P></P> 
</div> 
<div id="TweetContainer" > 
<P> 
</div> <!-- end tweetcontainer --> 
</div><!-- End demo --> 
</form> 
+0

http://jsfiddle.net/zxfMv/的jsfiddle鏈接到更正HTML – Jared 2012-03-16 21:18:29

+0

非常感謝你,這個工作,我不知道這個錯誤可能有這樣的影響......我知道了! :) – Neok75 2012-03-18 20:35:16