<html>
<head>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
function func(){
var s = "<p id=" + id +">"+"<center>"+"<h2><b>Topic :</b></h2>"+message+"</center></p><br>";
document.getElementById("stat").innerHTML+=s;
}
</script>
</head>
<body>
//call function func
<pre id="stat" > </pre>
</body>
</html>
Guys the function func is supposed to create a paragraph with id as "id " and the content as a message inside the tag with id as "stat " .. it works fine But i cant use the 'Jquery' selector to use the click function on
tag :/ ! the reason i am inserting inside in is i need the interpreter to consider "\n" as a new line. Why is that , not working ?
and is there any other way to do it ?
Attach the click event handler inside
func
:Or better still: