HTML Drop Down not selecting options in iPhone's IOS 13

1.1k Views Asked by At

I implemented a web application and it has a drop down (i.e., HTML Select). If I tried to select any option in the drop down its not triggering the change event but its updates the label text successfully.

  • Device: iPhone 11 or latest version
  • OS: IOS 13 or latest version
  • Browser: Safari

Sample Code:

<select id="storagetype">
    <option value="" selected>Select Storage Type</option>
    <option value="1" selected>ABC</option>
    <option value="2" selected>XYZ</option>
</select>

JavaScript:

var storagetype = document.getElementById("storagetype");

storagetype.addEventListener("change", function() {
    alert(storagetype.value)
});

If I tried the same in IOS 12.X or lower version its working as expected.

Moreover there is no console error and I tried the style z-index. But nothing worked.

enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

in below code add filter to detect iphone then use it.

Javascript:

 document.addEventListener('click', function (params) {
 document.querySelectorAll('li[id^="select-options"]').forEach(ele => {
 ele.addEventListener('touchend', (e) => {
 e.stopPropagation();
   })   
  }); 
});

Jquery:

$(document).click(function(){
  $('li[id^="select-options"]').on('touchend', function (e) {
    e.stopPropagation();
  }); 
});