How do I determine an HTML input element type upon an event using jQuery?

后端 未结 5 2065
逝去的感伤
逝去的感伤 2020-12-21 07:22

Given the following sample code:

$(document).ready(function(){
    $(\":input\").blur(function(){
        alert(\"The input type is:\" );  //How would this l         


        
5条回答
  •  独厮守ぢ
    2020-12-21 07:31

    $(this).attr("type");
    

    for example:

    $(document).ready(function(){
        $("input").blur(function(){
            alert("The input type is:" + $(this).attr("type"));
        })
    });
    

提交回复
热议问题