In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you javascript how to judge the existence of div, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Judgment method: 1, use the "document.getElementById (" id value ")" statement to obtain the div element object according to the specified id value; 2, use the if statement to judge whether div exists, and the syntax "if (div element object) {/ / element exists} else {/ / element does not exist}".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Js determines whether the div element exists.
When the native js getElementById () and getElementsByTagName () methods manipulate the element, if the manipulated element does not exist, the browser will throw an error and terminate the running of the code, so in order to avoid this situation, you can use the following code to determine whether the element exists when you are unable to determine whether the element to be manipulated exists.
Implementation code
Div element
This is a paragraph.
Var div=document.getElementById ("div"); if (div) {/ / the action code that the element exists console.log ("div element exists");} else {/ / the action code console.log ("div element does not exist") that does not exist;}
The above is all the contents of the article "how to determine the existence of div by javascript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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: 0
*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.