Get class content

Description

The following code shows how to get class content.

Example


<html>
<head>
<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--  ww  w.j a  va 2s. c  o  m-->
    $("p:last").addClass("selected highlight");
    alert($("p:last").hasClass("selected").toString());
  });
</script>
<style>
.selected {
  color: red;
}

.highlight {
  background: yellow;
}
</style>
</head>
<body>
<body>
  <p>A</p>
  <p>B</p>
  <p>C</p>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities