Home > Web Front-end > JS Tutorial > body text

What does style mean in JavaScript?

WBOY
Release: 2021-12-22 17:08:15
Original
5239 people have browsed it

Style in JavaScript means "style" and "setting style". The style attribute is a global attribute. You can change or set the style of an element in JavaScript. The syntax is "element object.style.style attribute = "Style attribute value ";".

What does style mean in JavaScript?

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

What does style mean in JavaScript

Style in JavaScript means style, setting style.

Style object represents a single style declaration. A Style object can be accessed from the document or element to which the style is applied.

The syntax is:

document.getElementById("id").style.property="值"
Copy after login

In many cases, it is necessary to dynamically modify the styles of elements on the web page. Provides methods for dynamically modifying styles in JavaScript.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
<p>无序列表:</p>
<ul>
  <li id="xuebi">雪碧</li>
  <li>可乐</li>
  <li>凉茶</li>
</ul>
<script type="text/javascript">
document.getElementById("xuebi").style.display="none";
</script>
</body>
</html>
Copy after login

Output result:

What does style mean in JavaScript?

##[Related recommendations:

javascript learning tutorial

The above is the detailed content of What does style mean in JavaScript?. 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