jquery 获取jquery对象的标签类型

//jquery 对象
$("#"+控件id)[0]


//查看控件类型

 $("#"+控件id)[0].type

实例1:
< select id="ddl" >
  < option >
1< /option >

   < option >2< /option >
< / select>

$("#ddl")[0].type;// select-one

实例2:
< input type="text" id="txt" />
$("#txt")[0].type;//text

实例3:
       < select id="Select1" >
            < option >1< /option >
            < option >2< /option >
            < option >3< /option >
        < /select >
       
        < select id="Select2" >
            < option >1< /option >
            < option >2< /option >
            < option >3< /option >
       

        < select id="Select3" >
            < option >1< /option >
            < option >2< /option >
            < option >3< /option >
        < /select >
       
        < input type="text" id="Text1" / >
        < input type="submit" id="Text2" / >
        < input type="button" id="Text3" / >

 //测试
        $$("select").change(function(){
            alert($$(this)[0].type); //select-one
        });
       
        $$("#Select1").change(function(){
            alert($$(this)[0].type); //select-one
        });
       
        $$("#Select2").change(function(){
            alert($$(this)[0].type); //select-one
        });
       
        $$("#Select3").change(function(){
            alert($$(this)[0].type); //select-one
        });
       
        $$("#Text1").click(function(){
            alert($$(this)[0].type); //text
        });
       
        $$("#Text2").click(function(){
            alert($$(this)[0].type); //submit
            return false;
        });
        
        $$("#Text3").click(function(){
            alert($$(this)[0].type); //button
        });

posted @ 2015-11-12 10:51  xtx  阅读(2953)  评论(0编辑  收藏  举报