This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14689|Reply: 1

[Jquery] jquery gets the label type of the jquery object

[Copy link]
Posted on 4/7/2018 1:54:29 PM | | | |
jquery object
$("#"+control id)[0]

//查看控件类型
$("#"+control id)[0].type



Both ways are fine


Example 1:
< select id="ddl" >
  < option >1< /option >

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

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

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

Example 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
        });





Previous:.net/c# Zookeeper Distributed Lock Implementation [Source Code]
Next:git is based on branch versioning
Posted on 4/8/2018 9:16:58 AM |
What is the use of getting types?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com