Execute javascript when clicking the combobox

Posted on

Question :

Is there any way I can run a script when I have a combobox open?


Answer :

The click event you can implement as follows:

document.getElementById("combobox").addEventListener("click", eventoClick);

function eventoClick() {
    alert("teste do onclick")

There is also the change event that is when you switch the combobox options:

document.getElementById("combobox").addEventListener("change", eventoClick); 

function eventoChange(){
        alert("teste do change")

And also mouseover :

document.getElementById("combobox").addEventListener("mouseover", eventoMouseOver);

function eventoMouseOver() {
    alert("teste do mouseover")

Follow the jsfiddle


Leave a Reply

Your email address will not be published. Required fields are marked *