How to add class to the last selected paragraph element and highlighting it.

 Posted by vishalneeraj-24503 on 2/4/2015 | Category: jQuery Interview questions | Views: 428 | Points: 40
Answer:

<!doctype html>

<html lang ="en">
<head>
<meta charset="utf-8">
<title>addClass demo</title>
<style>
p
{
margin: 8px;
font-size: 16px;
}
.selected
{
color: red;
}
.highlight
{
background: yellow;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p>DotNet</p>
<p>Funda</p>
<p>Website</p>
<script>
$("p:last").addClass("selected highlight");
</script>
</body>
</html>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response