javascript - Binding mouse events to dynamically created select -


i have created select tag dynamically in jquery function. want bind mouse events it. have dynamically created selct tag

function loadvalues() { var sel='<select id="flavor_slct'+index+'" class="popper" data-popbox="pop1"       onclick="alert()">'+flavor_fetched_string+'</select>'; $("#attach").append(sel);  } 

i have tried using .on() jquery function. still events not triggered.

$("body").on("hover","select",function()     alert("hovered"); )}; 

how should bind events dynamically created elements.?

there no hover javascript event triggered. looking mouseenter.

you have incorrect syntax defining function i've rectified:

$("body").on("mouseenter", "select", function(){     alert("hovered"); }); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -