@Todd
var select = document.getElementById('mySelect');
mySelect.addEventListener('mousedown', function() {
if( $(this).attr("data-IsOpen") == 1 ){
$(this).attr("data-IsOpen", 0);
}else{
$(this).attr("data-IsOpen", 1);
}
var isOpen = ($(this).attr("data-IsOpen") == 1);
console.log(isOpen);
});
What we do is add some attributes to the element, in this case, when you first click on the select element, it will request its IsOpen attribute for the data, since it does not exist, we will initialize it with a 1, indicating that the selection is open.
When we click on it again, we ask the same thing, now that it opens, we will update the attribute to 0, indicating that it is closed.
Hope this helps, Cheers.
source
share