js setAttribute removeAttribute


 

 1     <input type="button" value="生效" style="font-size:111px"/>
 2     <script type="text/javascript">
 3             //單擊"生效"按鈕,將其失效
 4         var buttonElement=document.getElementsByTagName("input")[0];
 5         buttonElement.onclick=function(){
 6             //添加屬性 
 7             this.setAttribute("disabled","true");
 8             //修改屬性
 9             this.setAttribute("style","font-size:10px");
10             //刪除屬性
11             this.removeAttribute("disabled");
12             //另一種修改方式  有些瀏覽器可能不知道
13             this.value="狗狗狗狗";
14         }
15     </script>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM