Как динамически добавлять / удалять класс CSS в jQuery
jQuery поставляется сaddClass() иremoveClass() для динамического добавления или удаления класса CSS. Например,
-
$(‘#para1’).addClass(‘highlight’); – Add a “highlight’ css class to elements that contain id of “para1”.
-
$(‘#para1’).removeClass(‘highlight’); – Remove a “highlight’ css class from elements that contain id of “para1”.
пример
jQuery add / remove css class example
This is paragraph 1
This is paragraph 2
This is paragraph 3
This is paragraph 4