Menu

Showing posts with label Find an attribute. Show all posts
Showing posts with label Find an attribute. Show all posts

Check and replace the attribute value using JS

 We can use JQuery to find the element and then we can replace the attribute value of an HTML element. Below is a JS code snippet to find and replace an attribute value.


$this.next().attr('aria-expanded', function(index, attr){

    return attr == 'false' ? 'true' : 'false';

});