code

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
 7    <script>
 8        $(document).ready(function(){
 9              var arr= ["kk","ct"];
10              //toUpper("kk");
11              toArrayUpper(arr);
12        });
13        
14        function toUpper(id){
15            $("#"+id+"").blur(function(){
16                $(this).val($("#"+id+"").val().toUpperCase());
17            })
18        };
19        function toArrayUpper(id){
20            var arr = id.toString().split(",");
21            for(var i=0;i<arr.length;i++){   
22              toUpper(arr[i]); 
23           };
24       };
25    </script>
26    
27 </head>
28 <body>
29   <input type="text" id="kk" value="">
30   <input type="text" id="ct" value="">
31   <input type="text"  value="">
32 </body>
33 </html>

  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

getComputedStyle 优雅
<style>
 #elem-container{
   position: absolute;
   left:     100px;
   top:      200px;
   height:   100px;
 }
</style>

<div id="elem-container">dummy</div>
<div id="output"></div>  

<script>
  function getTheStyle(){
    var elem = document.getElementById("elem-container");
    var theCSSprop = window.getComputedStyle(elem,null).getPropertyValue("height");
    document.getElementById("output").innerHTML = theCSSprop;
   }
  getTheStyle();
</script>

  

 

posted @ 2016-04-28 17:16  Moustache  阅读(150)  评论(0编辑  收藏  举报