Earlier I introduced some newly added selectors in HTML5, namely querySelector(), querySelectorAll() and getElementsByClassName(). These three have their own unique functions. If necessary, you can read the relevant content in HTML5 actual combat and analysis. Today I will introduce to you the classList attribute.
What exactly does the classList attribute do? Let’s leave classList alone for now. We consider such a question, how do we delete one of the category names of the elements of multiple categories? Dream Dragon's strong brain finally thinks of a implementation method.
will have a class name Li, Meng, and Long, and the category name meng in the three categories is deleted.
code is as follows
HTML代码 <p class="li meng long">梦龙小站</p> JavaScript代码 //获取要删除类名meng的p var
# 1. HTML5 actual combat and analysis of classList attributes
##:
# Previously introduced some selection device related to HTML5, which are querySelector (), querySelectorall () and GetelementsByClassName ( ). These three have their own unique functions. If necessary, you can read the relevant content in Html5 actual combat and analysis. Today I will introduce to you the classList attribute.
2. HTML5 actual combat and analysis CSS selector -GetelementsByClassName () method
Introduction:
## stequselector () method and querySelectOlLLL () method have been introduced in the previous few. No Do you know how well everyone understands?
Let’s review here. The querySelector() method returns the first element that matches the passed CSS selector; the querySelectorAll() method Returns all elements that match the passed CSS selector and is a NodeList object.
After a brief review, let me share a new method-getElementsByClassName() method.
[Related Q & A recommendation]:
Javascript -How to get GetelementsByClassName () arrays?
javascript -Why can't the following code be replaced with Class
#The above is the detailed content of How to use getElementsByClassName()? Summary of getElementsByClassName() instance usage. For more information, please follow other related articles on the PHP Chinese website!