0% found this document useful (0 votes)
8 views

Modify the DOM With JavaScript!

The document provides various JavaScript tips focused on DOM manipulation techniques. It covers methods for changing content with innerText and innerHTML, modifying attributes with setAttribute and removeAttribute, and managing classes with classList methods. The tips aim to enhance understanding of how to effectively manipulate HTML elements using JavaScript.

Uploaded by

gikame8539
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Modify the DOM With JavaScript!

The document provides various JavaScript tips focused on DOM manipulation techniques. It covers methods for changing content with innerText and innerHTML, modifying attributes with setAttribute and removeAttribute, and managing classes with classList methods. The tips aim to enhance understanding of how to effectively manipulate HTML elements using JavaScript.

Uploaded by

gikame8539
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

JavaScript tips

JavaScript
Dom Manipulation
2
Modifying Elements

Slim toumi
Slim toumi
JavaScript tips

Changing Content With


innerText

Explanation : Sets the text content of an element. It treats content as plain text
and doesn't parse HTML.

Slim toumi
Slim toumi
JavaScript tips

Changing Content With


innerHTML

New content

Explanation : allows you to change the content inside an HTML element


by replacing or adding HTML markup.

Slim toumi
Slim toumi
JavaScript tips

Changing Attributes with


setAttribute

Explanation : Sets the value of the specified attribute. Useful for custom
attributes like data-value.

Slim toumi
Slim toumi
JavaScript tips

Removing Attributes with


removeAttribute

Explanation : Removes the specified attribute from an element.

Slim toumi
Slim toumi
JavaScript tips

Setting And Getting


Properties

Explanation : Accessing and modifying properties, such as value


for form elements.

Slim toumi
Slim toumi
JavaScript tips

Add Classes With


classList

Explanation : classList provides methods to add classes on an element.

Slim toumi
Slim toumi
JavaScript tips

Removing Classes With


classList

Explanation : classList provides methods to remove classes on an element.

Slim toumi
Slim toumi
JavaScript tips

Toggling Classes With


classList

Explanation : classList provides methods to Toggles the presence of a class.


If the class is present, it removes it; otherwise, it adds it.

Slim toumi
Slim toumi
JavaScript tips

Checking For Class


Existence

Explanation : Checks if an element has a specific class and returns a boolean.

Slim toumi
Slim toumi
JavaScript tips

Hopefully You Found It


Usefull!
Be sure to save this post so you
can come back to it later

like Comment Share

Slim toumi
Slim toumi

You might also like