$('input:radio').click(
function(e){
if ($(this).is(':checked')){
$('p').show();
}
});
But atm all <p> elements are shown when the radio is checked. How would I modify this so only the <p> element that comes right after the radio-button is shown?
I tried something like this (beware jquery noob):
$('input:radio').click(
function(e){
if ($(this).is(':checked')){
$(this).next('p').show();
}
});
Hmm… well… yeah, the label might crimp it, a bit. What you had ($(this).next(‘p’).show() should do it… are you seeing any error messages in the console?
How would I modify this if I want the <p> to be hidden if the radio is not checked? Of couse I have the <p> as display: none in the CSS, but if i click another radio-button, which makes the current one unchecked, how do I then hide the <p>?
I tried this but it is not doing what i want it to:
$('input:radio').click(
function(e){
if ($(this).is(':checked', true)){
$(this).next().next('p').show();
} else if ($(this).is(':checked', false)) {
$(this).next().next('p').hide();
}
});