1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 <html> 3 <head> 4 <title>test_get_element_atts.html</title> 5 6 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 7 <meta http-equiv="description" content="this is my page"> 8 <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 9 <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> 10 <script type="text/javascript"> 11 function get_element_atts_val(obj) { 12 //获取button的value属性的值的各种方法 13 var value_1 = obj.value; 14 var value_2 = obj.getAttribute("value"); 15 var value_3 = obj.getAttribute("value"); 16 var value_4 = obj.attributes("value").value; 17 //alert(t); 18 alert(value_1 + value_2 + value_3 + value_4); 19 } 20 </script> 21 </head> 22 <body> 23 <!--以value为例 --> 24 获取button的value属性的值的各种方法 25 <br /> 26 <input type="button" name="t" id="d" 27 onclick="get_element_atts_val(this)" value="请点击" /> 28 </body> 29 </html>