Johan Johan -4 years ago 184
jQuery Question

Register a mouseover event on a <datalist>

so I'm starting to experiment with javascript/jquery and I have an input field with a datalist attached to it. The only problem I have is that when i "hover" over the datalist (once it appears) I want to trigger an event.

I have managed to trigger click and change events, but mouseover just won't work and I can't seem to find an example that works. Here is the code

<!DOCTYPE html>

<script src=""></script>
<script src=""></script>

<link rel="stylesheet" href="">

<script type="text/javascript">

// This works
$("#browserList").on("change", function(){
console.log("changed val=" + $(this).val());

// This does not



<input list="browsers" id="browserList" placeholder="Find a browser">
<datalist id="browsers">

Please tell me what I am missing,
Thank you!

Answer Source

For mouse over use the below syntex

  //do something

If you want to trigger the event on options of datalist, it's not possible because they are shadow elements. please see the explanation from another SO question. This explains better about it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download