Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get all classes of element jquery

var classList = $('#divId').attr('class').split(/s+/);
$.each(classList, function(index, item) {
    if (item === 'someClass') {
        //do something
    }
});
Comment

jquery get all classes of a div

var classes = $('#test').attr('class').split(' ');

alert(classes[0]); // first class
alert(classes[1]); // second class
alert(classes[2]); // third class
Comment

PREVIOUS NEXT
Code Example
Javascript :: react detect screen size 
Javascript :: jquery get multiple input values by name 
Javascript :: javascript object array iteration 
Javascript :: add property to string js 
Javascript :: js encode to & 
Javascript :: javascript create element in a new line 
Javascript :: file extension regex javascript 
Javascript :: how to remove element from array in javascript 
Javascript :: changing the active class on press 
Javascript :: how to use custom stylesheets express node 
Javascript :: js add style to each class 
Javascript :: react native image source local file 
Javascript :: js selection box excel node 
Javascript :: character limit regex 
Javascript :: electron getPath 
Javascript :: import { Application } from "express" 
Javascript :: angular window object 
Javascript :: difference between devDependency and dependency 
Javascript :: how to delete node_modules file 
Javascript :: the submitted data was not a file. check the encoding type on the form django react 
Javascript :: click outside element jquery 
Javascript :: get buffer from file javascript 
Javascript :: loop through map in js 
Javascript :: route parammap subscribe angular 9 
Javascript :: spring rest api cors error in react app 
Javascript :: chartjs stacked bar show total 
Javascript :: string array to int array javascript 
Javascript :: alternate color to table row jquery 
Javascript :: beautify json in html 
Javascript :: dotenv nodejs 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =