jquery select element with class name code example

Example 1: jquery get class name

//jQuery get class name of element 
var className=$('#myElementID').attr('class');

Example 2: select class with jQuery

// first make sure that jQuery is linked to your site or page
// add it in the <body> section before the closing body tag </body>
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
$(".yourClassName");

// you can also use classes that have dashes
$(".your-class-name");

// you can now use the selected element:
// for example to change color
$(".yourClassName").css("color", "red");

// change backgound color
$(".yourClassName").css("backgroud", "blue");

// change text
$(".yourClassName").text("Hey World!!!");

// change link attribute
$(".yourClassName").attr("href", "https://google.com");

// check attributes (href, src, alt etc...)
$(".yourClassName").attr("href");