Example of Disabled and disabled

Source: Internet
Author: User

Example of Disabled and disabled

You can set true and false for the Disabled attribute of the hyperlink to determine whether the hyperlink can be clicked.

For example:

<a herf='http://www.baidu.com' onclick='return click(this);' disabled='ture'>bai du</a>

The above means that you do not want to bring the super chain of bai du into effect, but do not make any constraints or judgment on click. However, when you click bai du, you will naturally jump to the Baidu page, this is a bug in the html Super Link disabling attribute.
You can add the following js constraints to determine whether a hyperlink can be used.

<script language='javascript'> function click(obj) { if(obj.disabled) { return false; } return ture; } </script>

The following is a bug solution provided by Microsoft:

With the help of global variables, you can use other buttons to change the disabled attribute to get the effect of the disabled attribute .;

BUG: the DISABLED attribute does not disable hyperlinks
Although the DISABLED property is set to True, a hyperlink is below,
<A DISABLED = "true" href = "http://www.microsoft.com/" rel = "external nofollow" rel = "external nofollow"> Where do you want to go today? </A>
You can still click the hyperlink and then navigate to the selected page in Internet Explorer.

To solve this problem, set the onclick event that returns true or false Based on the hyperlink of the current execution context. In the following code, set the global Microsoft JScript variable value to true or false. click the button. The DISABLED attribute of the target hyperlink object is updated so that it can correctly communicate with its DISABLED status. Other objects can be used to compile functions on this page.


Js or jquery switchover settings hyperlink flag unavailable <a> urgent

<A> custom attribute unable! It seems that the disabled attribute has only one value: disabled.
<A id = "addGrade" href = 'javascript:; 'unable = "false" onclick = 'if (! Isdis (this) addGrade () '> Add Grade </a>
<A id = "addClasses" href = 'javascript:; 'unable = "false" onclick = 'if (! Isdis (this) addClasses () '> Add a class </a>
<A id = "del" href = 'javascript:; 'unable = "false" onclick = 'if (! Isdis (this) del () '> Delete selected </a>
Function go (btns ){
$ ("# AddGrade, # addClasses, # del"). attr ("unable", true );
$ ("# AddGrade, # addClasses, # del"). addClass ('disable ');
$ (Btns). attr ("unable", false );
$ (Btns). removeClass ('disable ');
}
Function isdis (t ){
Return $ (t). attr ('unable') = "true ";
}

What CSS is used to control the disabled attribute of a link?

#2. You can still open the link. When you click the link, set the <a> href attribute to null using the script.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.