Elements with particular class can be easily accessed with jQuery . As per jQuery function syntax , starts with $ then in parenthesis we will pass the class name with dot ( . ) at the start.
$(".ClassName");
We are now going to building our jQuery Class access by Example below.
First we will get access to the HTML elements with class="myclass" then using the jQuery CSS function css() function we will assign the dashed border.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="myclass"> Click Me </button>
<div class="myclass" >Welcome to CodingPk jQuery Tutorial Get Element By Class </div>
<script type="text/javascript">
$("button").click(function()
{
$(".myclass").css("border","dashed 1px red");
});
</script>
$(".myclass").eq(1).css("border","solid red 1px");
Index will start from 0.