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>
OK, after your update it seems that the only problem was in multiple elements with the same ID. Please consider that IDs of the elements should be unique.
Remove
idattributes from radio buttons or change its’ values and check how it works.DEMO: http://jsfiddle.net/g4v3P/