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