0

I am switching between different projects by on change event on select element. I am getting them from DB. But before loading different project i have to store name of previous one.For that i am using on focus event.

How can i then deselect my select element?

document.getElementById("selectProject").selected = false;

is not working.

 var whichProjectToSave;

    function onFocusSelectProject(){
    //for saveJsonF();
    whichProjectToSave=document.getElementById("selectProject").value;
    }


function callSettingswindow(){       
 saveJsonF();
 canvas.clear();
 getJsonF();////////////////////////////////////                              
 document.getElementById("selectProject").selected = false;   
}    
document.getElementById("selectProject").onchange= callSettingswindow;

To make it clear: How to deselect "select" element after change is performed?

1 Answers1

0

I am not aware of any methods that will let you "de-focus" from an element. But you could focus on any other element - as a result the select element will lose focus.

You could make use of jQuery if you wanted to programmatically focus on the element with next tab index. See this answer for more details.

Nisarg Shah
  • 14,151
  • 6
  • 34
  • 55