search
HomeCommon ProblemHow to change the type attribute of input in jquery

Jquery method to change the type attribute of input: 1. Create an html file and introduce the jQuery file; 2. Create an input box with the input tag in the P tag, and set the default value of value to abcdefg, input tag The ID is tuiput; 3. Create a button with the button tag and bind the onclick event; 4. Use the "$('#tuinput').attr('type','password');" syntax.

How to change the type attribute of input in jquery

The operating system of this tutorial: Windows 10 system, jQuery3.6.0 version, Dell G3 computer.

jquery changes the type attribute of input through the "attr()" method:

1. Create a new html file, name it test.html, and introduce it in the head jQuery file

How to change the type attribute of input in jquery

2. In the html file, within the p tag, use the input tag to create an input box, and set its default value to abcdefg

How to change the type attribute of input in jquery

3. In the test.html file, set the id attribute value of the input tag to tuinput, which is mainly used to obtain the input object through this id below

How to change the type attribute of input in jquery

4. In the test.html file, use the button tag to create a button with the button name "Change the type attribute of input"

How to change the type attribute of input in jquery

5. In test. In the html file, bind the onclick click event to the button button. When the button is clicked, the editype() function is executed

How to change the type attribute of input in jquery

#6. In the js tag, create editype() Function, within the function, obtain the input object through id (tuinput), use the attr() method to change the type attribute value to password

How to change the type attribute of input in jquery

7. Open the html file in the browser, Click the button to see the effect

How to change the type attribute of input in jquery

How to change the type attribute of input in jquery

The above is the detailed content of How to change the type attribute of input in jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),