html - How do I append a string to a selected option in a drop down list without having it shown in the list itself? -


i have drop down list follows:

<select id='list'> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> </select> 

however, on selection of 1 of these options, need see option selected "option selected / number of options". example, if select 1, need drop down show "1/3" , not "1". essentially, need "/3" part appended option selected. have ideas this? because seem have run out of mine.

i think must looking this, can done using simple jquery.

html:

<select id='list'>   <option value='1/3'>1</option>   <option value='2/3'>2</option>   <option value='3/3'>3</option> </select> <div> </div> 

jquery:

$("select").change(function(){ var str = $("#list").val(); $("div").html(str); }); 

fiddle: https://jsfiddle.net/shishirmax/rmg75xs3/


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 -