问题
My naive approach is the following:
function isClickable(id){
elem = document.getElementById(id);
if (elem.nodeName.toLowerCase() == 'a' || typeof(elem.click) != 'undefined'){
return true;
}else{
return false;
}
}
Is there anything better I can do?
来源:https://stackoverflow.com/questions/5632016/javascript-how-to-check-if-an-element-is-clickable-or-not