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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -