Home >Web Front-end >HTML Tutorial >JS implements method of locking HTML page elements when loading
This article mainly introduces the JS method of locking HTML page elements when loading, involving JavaScript's implementation skills related to traversal and attribute operations of page elements. Friends in need can refer to the following
The examples of this article are described JS implements the method of locking HTML page elements when loading. Share it with everyone for your reference, the details are as follows:
When the html is loaded, js locks all input, textarea, and select in the page. The specific js is as follows
index.js
for(z=0;z<document.getElementsByTagName('input').length;z++) { document.getElementsByTagName('input')[z].setAttribute('disabled','disabled') } for(zz=0;zz<document.getElementsByTagName('textarea').length;zz++) { document.getElementsByTagName('textarea')[zz].setAttribute('readonly','readonly') } for(zzz=0;zzz<document.getElementsByTagName('select').length;zzz++) { document.getElementsByTagName('select')[zzz].setAttribute('disabled','disabled') }
Related recommendations:
js method to get the value of the span tag in html (super simple)
The above is the detailed content of JS implements method of locking HTML page elements when loading. For more information, please follow other related articles on the PHP Chinese website!