I have a problem with show/hide some text input by using jQuery-UI buttonset() function. Here is the HTML:
<div id="issubtitled">
<input type="radio" id="unsubtitled" name="su开发者_Go百科btitled" checked="checked" /><label for="unsubtitled">No Sub-Title</label>
<input type="radio" id="subtitled" name="subtitled" /><label for="subtitled">With Sub-Title</label>
</div>
<p id="psubtitle">
<label>Sub-Title: </label>
<input type="text" id="subtitle" name="subtitle" value="" />
</p>
In this form, I want to show and hide the #psubtitle when the users select the buttonset. Please note that I use jQuery-UI buttonset() in the following .js code:
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j("#psubtitle").hide();
$j("#issubtitled").buttonset().click(function(){
/* what should I do there? */
return false;
});
});
http://jsfiddle.net/rlemon/uV9uG/
You need to determine which radio option is being selected, I just used their ID's
also you want to use class names for the blocks you want to hide, then you can hide multiple ones at once. Look at my example above.
or you can make it even smaller.. probably more efficient. http://jsfiddle.net/rlemon/uV9uG/7/
do you mean:
$j("#psubtitle").show();
精彩评论