Set HTML content in jQuery

Description

The following code shows how to get HTML content.

Example


<!DOCTYPE html>
<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
  <!--  w w w .  java 2 s.c  o  m-->
</script>
<script>
  $(function() {
    var content = $("div").html();
    document.writeln(content);
    $("div").html("<p style='color:red;'>RED</p>");
  });
</script>
</head>
<body>
  <div>
    <ul>
    </ul>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities