Home > Web Front-end > JS Tutorial > jquery a tag is not available implementation method

jquery a tag is not available implementation method

藏色散人
Release: 2023-01-04 09:36:38
Original
2097 people have browsed it

jquery How to implement the unavailable a tag: First create a sample file; then use jQuery to make the a tag unavailable, with statements such as "if (boolean) {$("a").attr( "disabled", true)...}".

jquery a tag is not available implementation method

The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer. This method is suitable for all brands of computers.

Recommendation: "jquery video tutorial" "javascript basic tutorial"

##jquery makes a tag unavailable

Sometimes, we need to make the a tag unavailable under certain conditions. However, due to the special nature of the a tag, just adding the disabled attribute to it can only make it gray, and it will still jump when clicked. transfer, so other processing is required.

Here is a method of using jQuery to make a tag unavailable:

if(boolean){
    $("a").attr("disabled", true);
    $("a").click(function(){});
}
Copy after login

In fact, it is to gray out the tag and set its jump function to empty, native JS and other frameworks can be implemented by referring to this method.

or

$("a").attr("disabled", true);
$('.disableCss').removeAttr('href');//去掉a标签中的href属性
$('.disableCss').removeAttr('onclick');//去掉a标签中的onclick事件
Copy after login

If there is a data-toggle switch attribute of the tab page, you need to add a $(".disableCss").removeAttr('data-toggle');

The above is the detailed content of jquery a tag is not available implementation method. For more information, please follow other related articles on the PHP Chinese website!

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