There are related drop-down lists and in the second list, the class assigned to the first one. How to make the js script run only for a certain class value? These 2 codes (drop-down list and JS code with the output of the current date) are individually all workers. I also need to make a link so that if I select a specific value in the second drop-down list (let's say with class="chiv" ), then 2 (which is JS) the code started to work and output its picture (as a result, it should show two images, one from the drop-down list and one from JS code). If with another class, then the JS code would simply be skipped.

 <select id="programming"> <option value="">...</option> <option value="chiv">Животные</option> <option value="ptic">Птицы</option> <option value="rast">Растения</option> </select> <select id="categories"> <option value="">...</option> <option value="img\зебра.jpg" class="chiv">Зебра</option> <option value="img\лев.jpg"class="chiv">Лев</option> <option value="img\аист.jpg" class="ptic">Аист</option> <option value="img\дуб.jpg" class="rast">Дуб</option> </select> 

And here is the JS code

 <script> var day=new Date(); var pictures = ['Sunday.png', 'Monday.png', 'Tuesday.png', 'Wednesday.png', 'Thursday.png', 'Friday.png', 'Saturday.png']; document.write('<img src="' + pictures[day.getDay()] +'">'); }; </script> 

    1 answer 1

    You can make a check on the class , and if true perform the function. It is possible to make a check not by class , but by option , I don’t see any difference, by the way it will be easier.

    https://stackoverflow.com/questions/10213620/how-to-check-if-an-option-is-selected

    http://jquery-docs.ru/traversing/is/

    • And how to make on class check? - ilya1099