Home:ALL Converter>jQuery Mobile radio button (show/hide div)?

jQuery Mobile radio button (show/hide div)?

Ask Time:2012-05-22T02:11:17         Author:acctman

Json Formatter

Is there a simple way to attach an anchor link to radio button or maybe a show/hide div... I currently have to radio option buttons on a page and I would like for the text within a div to change out when the alternate option is select. here is what I'm trying so far. So far no luck

<style type="text/css">
    .nutwork { display: none; }
</style>
<script type="text/javascript">
    $(document).ready(function(){ 
        $("input[name=nutwork]").change(function() {
            var test = $(this).val();
            $(".nutwork").hide();
            $("#"+test).show();
        }); 
    });
</script>
    <div data-role="fieldcontain" class="no-field-separator">
        <div class="center_group">
         <fieldset data-role="controlgroup" data-type="horizontal">                  
           <input type="radio" name="nutwork" id="radio1" value="radio1" checked="checked"/>
           <label for="radio1">
            Item 1
           </label>
           <input type="radio" name="nutwork" id="radio2" value="radio2"  />
           <label for="radio2">
            Item 2
           </label>
         </fieldset>
        </div>
     </div>

<div id="radio1" class="nutwork">
Test
</div>

<div id="radio2" class="nutwork">
Test item 2
</div>

Author:acctman,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/10690361/jquery-mobile-radio-button-show-hide-div
yy