Home>Article>Web Front-end> How to make the cursor disappear with jquery
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")".
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:
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"); }); });
[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!