Thursday 15 May 2014

javascript - jquery show hide div based on select value -


I have a selection list with Valence 'All' and 'Custom' on the 'div' selection with the value 'custom' 'A div should appear with resources, and if the value is' all', then it should be hidden.

The form is:

  & lt; Div & gt; & Lt; Label & gt; Privileges: & lt; / Labels & gt; & Lt; Select name = "privilege" id = "privilege" class = "" onclick = "buyer userzobs.shoppillagez ();" & Gt; & Lt; Option id = "all" value = "all" & gt; All & lt; / Options & gt; & Lt; Option id = "custom" value = "custom" & gt; Custom & lt; / Option & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; Div class = "resource" style = "display: none;" & Gt; Resources & lt; / Div & gt;   

and it has JavaScript for:

  appearances: function () {var specialization = jQuery ('# privileges'); Choose Var = this.value; Privileges.change (function () {if (select === 'custom') {$ ('resource'). Show ();}}); }   

How should this look to work? Sorry, I know it should be simple, but I'm new to it all.

You can use:

  var privileges = jQuery ('# Privilege '); Choose Var = this.value; Privileges.change (function () {if ($ (this) .val () == 'custom') {$ ('. Resource'). Show ();} else $ ('. Resources'). Hide () Hide // div if the value is not "custom"}};   



No comments:

Post a Comment