Javascript – jquery click question

javascriptjquery

i have an issue.

the code is this:

$("#button").click(function(event){
   $("#threads").html("hi");
});

when i click the button, the text "hi" is just shown in 1 sec. then it disappear. i want it to always be shown after i have clicked. how can i do this?

Best Answer

Try this:

$("#button").click(function(event){
   event.preventDefault();
   $("#threads").html("hi");
});

My guess is button is an [a href] tag or in a form which is causing the page to refresh.