In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today Xiaobian to share with you how jquery judges whether the element has disabled attribute related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you have read this article after harvest, let's learn about it together.
Judgment method: 1. Use "element to be judged.attr("disabled");" to obtain the disabled attribute value of the element;2. Use "if(obtained element disabled attribute value =="disabled"){element has the code of this attribute;}" to judge.
Operating environment for this tutorial: Windows 10 system, jquery version 3.2.1, Dell G3 computer.
How does jquery determine if an element has a disabled attribute?
1. Use attr method to get disabled attribute of attribute
The attr() method sets or returns the properties and values of the selected element.
When this method is used to return attribute values, it returns the value of the first matching element.
When this method is used to set attribute values, one or more attribute/value pairs are set for the matching element.
syntax
Returns the value of the attribute:
$(selector).attr(attribute)
2. Use the if loop to judge
if statement if(conditional expression){ Statements... }
When the if statement is executed, the conditional expression will be evaluated first.
If the conditional expression is true, the statement after if is executed,
If the conditional expression has a value of false, the statement after if is not executed
An if statement can only control the statement immediately following it.
If you want an if statement to control multiple statements, you can put them together in a block {}
The code block after the if statement is not necessary, but try to write the code block in development, even if there is only one statement after the if statement.
Examples are as follows:
123$(document).ready(function(){var res=$("#mybutton").attr("disabled");if(res=="disabled"){alert ('this element has disabled attribute');}}); elements with disabled attribute
Output:
The above is "jquery how to determine whether the element has disabled attribute" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 285
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.