How to toggle based on saved radio button selections using jQuery?

Not sure if this is what you want, but you could chain the change method on to your change handler.

Not sure if this is what you want, but you could chain the change method on to your change handler - $('. Toggle'). On('change',function(){ var showOrsiblings('inputtype=radio').andSelf().

Each(function() { if ($(this).val() == 1 && $(this). Prop("checked")) showOrparent(). Next('#details').

Toggle(showOrchange() That should call the change method on loading the page and hide anything that your logic states should be hidden. I've also changed logic slightly so the values of sibling radio buttons are also checked. Demo - jsfiddle.net/sBErV/2.

That's close. The only issue is that if one of the options is selected 'yes', the div should be visible when the form is loaded. See jsfiddle.Net/58xqM/2 – Michael Nov 25 at 22:47 I've added a fix to this fiddle - jsfiddle.

Net/58xqM/4 – ipr101 Nov 25 at 23:45 This doesn't seem to be working as the Select #2 is marked as 'yes', but the div is still hidden when the page loads. – Michael Nov 25 at 23:49 Sorry - pasted the wrong link, should have been - jsfiddle.Net/58xqM/6. Hope that works!

– ipr101 Nov 26 at 0:40 @irpr101 quick question, why does it break if I change the first option to 'no' and second option to 'yes'. Jsfiddle.Net/58xqM/7 how would the jquery change if this were the case? – Michael 01 Nov1 at 14:59.

This is a relatively simple approach to hide the div following a div that contains an input of value="0" that's also checked: $(document). Ready(function() { $('div:has("inputvalue=0:checked")'). Next('div').hide(); }); JS Fiddle demo.

Please note that you've got two elements sharing the same id. This is invalid according to the html spec: id = name case-sensitive This attribute assigns a name to an element. This name must be unique in a document.Reference.

Updated, with a slightly improved approach: function showde(){ $('div:has("input:radiovalue=0:checked")'). Next('div').hide(); $('div:has("input:radiovalue=1:checked")'). Next('div').show(); }; $(document).

Ready(function() { showchange( function(){ show JS Fiddle demo.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions