How To Check Class Of Multiple Class Elements In Javascript, Without Jquery
I have the following javascript code to put the uploader name before the upload date and view count in youtube search results. function hasClass(element, cls) { return (' ' + e
Solution 1:
element.classList
It would return you the array of all the classes present on the element
like ["site-icon", "favicon", "favicon-stackoverflow"]
, so then by using normal javascript you can implement hasClass functionality of your own.
So your hasClass function becomes
functionhasClass(element, cls){
return element.classList.contains(cls);
}
Post a Comment for "How To Check Class Of Multiple Class Elements In Javascript, Without Jquery"