class - JQuery Hide Div when Option is Selected -


When I select a specific option value, I want to hide a class of one class

  & lt; Id = "tag type" name = "type" & gt; & Lt; Option value = "type_s" & gt; Standard & lt; / Option & gt; & Lt; Option value = "type_o" & gt; Overstock & lt; / Option & gt; & Lt; Option value = "type_send" & gt; Scratch & amp; Amp; Dent & lt; / Options & gt; & Lt; Option value = "type_multi" & gt; Coefficient & lt; / Options & gt; & Lt; / Select & gt; & Lt; Div class = "multiples" gt; Stuff here & lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () (if ($ ("(# $ tagtype [value = 'type_mult']"). Length) $ ("multiples"). CSS ('display', 'none') ;});    

  jQuery (document) .ready (Function () (jquery (". Multiplier"). {("(Coefficient: selected)" .val () == "type_mult") {jQuery (". Multiplier"). ();}})}} ;   

You are binding a handler at the On Change event of the selected box. Whenever you select a new option in the selection box, the handler is called.

In Nederler, this refers to the selection box that removed the on change event.Moder of the selected option. If this value is equal to "type_mult", then you square

The problem with your existing code is that it will run only once; When the page is loading first, you will be able to select the code in the selected box. The changes will have to be answered, which is why you have to pair with the on change event Another problem is that if statement even if you have used your code and in On Change handler, enter it because you do not see what the option is with "type_mult" selected. You're just checking to see if it's present. Since it always is present, if the code inside will always be continued, when you want to use the names of the square, then you have to keep a period in front of the class name. Will happen. Then you do not want to $ (.x. Multiplier) and just do not want to $ (multiples) (the latter multiples tag, which will It is not what you want)

Comments