使用JS獲取具有焦點控件的ID:
複製代碼代碼如下:
$("#textID").click(function(){
var act = document.activeElement.id;
if(act == "textID" ){
alert("true");
}else{
alert("false");
}
} );
使用jquery獲取具有焦點控件的ID:var act = $(document.activeElement).attr("id");
----------------------<input type="text" id="textID">