Home > Web Front-end > JS Tutorial > JS gets all text controls in the page input control and appends style attributes_javascript skills

JS gets all text controls in the page input control and appends style attributes_javascript skills

WBOY
Release: 2016-05-16 17:41:38
Original
1139 people have browsed it

As mentioned, jquery will be used to obtain all text controls in the page input control and add styles when the page is loaded.

The width attribute of the text control used on the page I wrote before is too small and needs to be changed. The change involves all the text attributes on the page. It feels very troublesome to change the width of each control, so I want to change it through the page. When loading, find the text to be changed and add attributes.

First I wrote a css style:

Copy the code The code is as follows:

.wid
{
width:205px;
}

The code written in page loading is as follows:
$("input[type=text]").addClass("wid"); //Get all type=text controls in the input control and add styles to the text text box. This is complete.
javascript gets the page control and appends the style:
Copy the code The code is as follows:

/ /Add a style to the select drop-down box
var g=document.getElementsByTagName("select"); //Set a variable to receive the found select control
for(i=0;i{
document.getElementById(g[i].id).style.width="210px"; //Additional style
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template