Add new html tag to body and set its class name in jQuery
Description
The following code shows how to add new html tag to body and set its class name.
Example
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.titleText {<!-- ww w. j a va2 s . co m-->
color: green;
font-family: arial;
}
</style>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function() {
$("<h1>This is a header</h1>").appendTo("body").attr("class",
"titleText");
});
</script>
</head>
<body>
</body>
</html>