How to handle dropdown with javascript?

  • 0
    Good day everyone!
    would like to ask for help clarifying the implementation,
    I rummaged through the Internet, but there are some dry examples of simple html, and unfortunately I could not find a handler or an example of implementation of at least an approximate one.
    so there is a code like this:
    <select name="" id="">
    	<option><p class="coin" atr="stad">по дате</p></option>
    	<option><p class="coin" atr="coal">с начало дешевле</p></option>
    	<option><p class="coin" atr="my">с начало дороже</p></option>

    here I tried to process such code through js so that when fetching the current attribute (using a loop to it a handler) and implementation
    but if it's just a paragraph, for example, then it selects and the conditions work - but inside select option p, it doesn't see a click - and I don't know how to implement the drop-down list.

    I need it like this - that I would select something from the list and go to a certain page.
    but i'm not much confused and lost the thread.

    and I need it in js, in php I know how to do it - but I want it in js
    If I'm not really stupid, then if someone has the opportunity to suggest the implementation, I will be very grateful!
    JavaScript Anonymous, Jul 2, 2020

  • 3 Answers
  • 0
    And where do you, gentlemen, take such examples?

    Henry Vazquez

  • 0
    Select has its own event - change. Fires when the value changes.

  • 0
    PS Click events for Select items in Safari do not work, wait 10 years - maybe they will.

    let el = document.getElementById('my_slect');
    el.addEventListener('change', function(e){
    let value =;
    if(value === 'option value'){
    location.href = ''; // ссылка для редеректа

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!