Adding CSS Class to the Last Selected Paragraph Element using jQuery.

vishalneeraj-24503
Posted by vishalneeraj-24503 under jQuery category on | Points: 40 | Views : 162
Reference jQuery library as shown below:-
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<p>vishal</p>
<p>kumar</p>
<p>neeraj</p>
<style>
p
{
margin: 8px;
font-size: 16px;
}

.selected
{
color: blue;
}

.highlight
{
background: yellow;
}
</style>

//jQuery code here
<script>
$("p").last().addClass("selected");
</script>

Comments or Responses

Login to post response