Set harcoded HTML content in jQuery

Description

The following code shows how to set harcoded HTML content.

Example


<!--from ww  w . j  av a  2s . c o  m-->
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</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

The code above generates the following result.

Set harcoded HTML content in jQuery
Home »
  Javascript Tutorial »
    jQuery »
      jQuery DOM
...
Map each list item to uppercase in jQuery
Map parents to get its name in jQuery
Map value with index and value in jQuery
Remove an attribute by name in jQuery
Remove element from selected list by its st...
Remove element from the selected list by id...
Remove just added in hover event in jQuery
Remove select elements which contains a cer...
Replace all in click event for clicked elem...
Replace all paragraphs with hard coded elem...
Replace clicked element and keep its text i...
Replace with hard coded tag in jQuery
Reverse of $(A).before(B) with .insertBefor...
Reverse the $(A).after(B) with $(A).insertA...
Reverse the result of $(A).append(B) in jQu...
Set HTML tag as text in jQuery
Set Image URL, title and alt by passing in ...
Set attribute value with attr and a functio...
Set div element text value in jQuery
Set harcoded HTML content in jQuery
Set html content with function to create co...
Set image src in jQuery
Set paragraph content and apply style in jQ...
Set text for a selected paragraph with .tex...
Set the hardcoded html tag to a selected ta...
Set the previous element in click event han...
Set the text for first span in jQuery
Set the vertical scroll bar value in jQuery
Switch node sequence with .insertBefore in ...
Switch the sequence of two tags in jQuery
Switch with .is() method in jQuery
Use map function to get value from input el...
Wrap Inner elements with new created elemen...
Wrap inner content with border with wrapInn...
Wrap more than one hard coded element to pa...
Wrap selected the content of a paragraph in...
Wrap with border in jQuery
Wrap with div element in jQuery
...