Home>Article>Web Front-end> How to make the cursor disappear with jquery

How to make the cursor disappear with jquery

青灯夜游
青灯夜游 Original
2022-05-23 17:25:57 2332browse

Two methods: 1. Use css() to set the cursor color style, the syntax is "element.css("caret-color","transparent")"; 2. Use attr(), the syntax is "element. attr("style","caret-color:transparent")".

How to make the cursor disappear with jquery

The operating environment of this tutorial: windows7 system, jquery3.2.1 version, Dell G3 computer.

In HTML, you can make the cursor disappear by setting the cursor color to transparent, that is, adding thecaret-color:transparent;style;

The following introduces jquery settings for transparency Two methods of cursor.

Method 1: Use css() to directly set the caret-color attribute

The css() method sets or returns one or more style attributes of the selected element.

Just set the value of the caret-color attribute to transparent.

元素对象.css("caret-color","transparent");

Example:

      


How to make the cursor disappear with jquery

2. Use attr() to set the style attribute and add caret-color:transparent; style

attr() can set element attributes.

Just set the style attribute and add caret-color:transparent; inline style.

Example:

$(document).ready(function() { $("button").click(function() { $("input").attr("style","caret-color:transparent"); }); });

How to make the cursor disappear with jquery

[Recommended learning:jQuery video tutorial,web front-end video]

The above is the detailed content of How to make the cursor disappear with 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