Hello. there is

<select id="start" onchange="calcRoute();"> <option value="*****">*****</option> <option value="*****">******</option> <option value="******">******</option> 

How via Jquery or Js to add more options to it or remove ???? Thank you

    1 answer 1

    You can add it like this:

     var $_container = $('#start'); $_container.append('<option value="*****">*****</option>'); 

    Delete:

     var $_element = $_container.find('option[value = ******]'); $_element.remove(); 
    • but let's say I have a variable, and I want to put it in a value, what then? - elik
    • You can do this: $ _container.append ('<option value =' + value + '> ***** </ option>'); where value is your variable - Mikl
    • right now I will try) we will see) - elik
    • Everything works ok) - elik