addEventListener не работает в Chrome

Рейтинг: 0Ответов: 0Опубликовано: 18.05.2023

В js коде есть такой кусок

.done(function(data) {
        for (const item of Object(data)) {
            option = document.createElement("option");
            option.text = item;
            option.addEventListener("click", get_domains, false);
            option.selectParam = item;
            dropdown_centres.appendChild(option);
        }
    });

В Firefox всё работает. В Хроме и Яндекс браузере в строчке

option.addEventListener("click", get_domains, false);

функция get_domains не вызывается. В чем может быть причина?

upd. Дополняю вопрос примером кода.

function get_domains(evt) {
  console.log('GET DOMAINS')
}


function get_data_centres() {
  const data = ["Default"];

  let dropdown_centres = document.getElementById("data_centerList");
  for (const item of Object(data)) {
    option = document.createElement("option");
    option.text = item;
    option.addEventListener("click", get_domains, false);
    option.selectParam = item;
    dropdown_centres.appendChild(option);

  };
}

get_data_centres()
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>

<body>
  <form id="recovery_form">
    <table id="recovery_table">
      <tbody>
        <tr>
          <td>Дата-центр</td>
          <td>Домен хранилища</td>
        </tr>
        <tr>

          <td>
            <div class="select_data_center">
              <select name="data_center" id="data_centerList">
                <option value='option1'>--выбрать--</option>
              </select>
            </div>
          </td>
          <td>
            <div class="select_domain">
              <select name="domains" id="domainList" style="width:150px;"></select>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </form>
</body>

</html>

Ответы

Ответов пока нет.