How to implement jQuery to get elements by class name?

There is no "getElementsByClass" function in javascript,

then how to do jQuery?

Cycling all elements will be less efficient.

By the way, how to specify css for elements with two or more classes?

<a class="one two">test</a>

Guess how down below?

.one.two {...}

Is it correct?

+3
source share
2 answers

The getElementsByClassName function exists, jQuery uses it internally, if available, check the selector.js file in the jQuery source

To select items with multiple classes, use the .class.class selector:

$('.one.two')
+3
source

jQuery Sizzle.

+2

Source: https://habr.com/ru/post/1715500/


All Articles