css - How to show list items got selected in javascript -
i have number of list items sports, music, dance etc. have images related them. want is, when click on image of sports, list item 'sports' seen selected. beginner in java script , not understand how make possible.
this should working approach your, information missing, question. wrote show how can work can adapt solution code.
js:
$('img').click(function() { match = $(this).attr("match"); $('select').val(match); }
html:
<img src="1.jpg" match="sport"/> <img src="2.jpg" match="dance"/> <select name="list" value=""> <option value="sport">sport</option> <option value="dance">dance</option> </select>
here can see jsfiddle: https://jsfiddle.net/1lw2gupj/2/
Comments
Post a Comment