+ 1

How can I use jquery fadein in html select options ?

<select> <option id="option1" value="a"> a </option> <option id="option2" value="b"> b </option> </select> <p id="p1"> Paragraph 1 </p> <p id="p2"> Paragrahp 2 </p> what I want to happen is when I select option 1, the p1 will show and when I select option 2, the p2 will show. I already use the display:none on the paragraph. this is my jquery $("option1").click(function(){ $("p1").fadeIn(); }); the same for option 2. but it's not working Help me plss.

20th Mar 2018, 2:13 PM
Naruto Shippuden
Naruto Shippuden - avatar
2 odpowiedzi
+ 1
You use change() function $("select").change(function() { if($(this).val() == "a") { $("#p1").fadeIn(); } });
20th Mar 2018, 3:27 PM
Toni Isotalo
Toni Isotalo - avatar
0
thank you so much it works 😀
21st Mar 2018, 5:59 AM
Naruto Shippuden
Naruto Shippuden - avatar