Set html content with callback function
Description
The following code shows how to set html content with function to create content dynamically.
Example
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
<!--from w w w .j av a 2 s . co m-->
</script>
<script>
$(function() {
$("div#testHTML").html(function() {
var content = "";
for (i = 1; i <= 3; i++) {
content += "testing " + i + "...<br />";
}
return content;
});
});
</script>
</head>
<body>
<div id="testHTML"></div>
</body>
</html>