jQuery build in logic change -



jQuery build in logic change -

i new jquery help me one? have function executes on value change. used on building search. need fire function not on value alter , whenever value equal specific one. logic in words:"hide ids, if select[id] has value or value changed - if else constrution" can help me rebuild fires on both cases? think mashup between .change , .val functions might help here.

<script> jquery(document).ready(function ($) { $("#other_field_id").hide(); $("#some_field_id").hide(); $("select[id=what_to_show]").change(function(){ var myvalue = $("select[id=what_to_show]").val(); if (myvalue == 'other-value'){ $("#other_field_id").show(); } else if (myvalue == 'some-value'){ $("#some_field_id").show(); } }); }); </script>

modify below code

jquery(document).ready(function ($) { $("select[id=what_to_show]").change(function(){ $("#other_field_id").hide(); $("#some_field_id").hide(); var myvalue = $("select[id=what_to_show]").val(); if (myvalue == 'other-value'){ $("#other_field_id").show(); } else if (myvalue == 'some-value'){ $("#some_field_id").show(); } }); });

thing have done wrong hiding values @ time of document load not on changing value.

jquery

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -