Can we select a element having a specific class in jQuery ?

 Posted by Bharathi Cherukuri on 2/6/2012 | Category: jQuery Interview questions | Views: 2319 | Points: 40

Yes, we can select an element with a specific class, we use the class selector.The class name must contain the prefix as "." (dot).

<script language="javascript" type="text/javascript">

$(".class1").css("border", "2px solid red");


Above code will select all the elements of the webpage containing the class as "class1" and apply the css style border width as 2 Pixel, style as solid and color as red.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response