I want to show or hide preview content on a click. So I use toggle effect with jQuery.
But I can not hide the preview, if it was activated by a first click.
Here is my jQuery code…
$("#show").click(function () {
$('#editor').toggle();
$('#preview').hide();
$("#rte").keypress(update);
function update() {
$('#preview').slideDown('slow');
var rte = $('#rte').val();
$('#preview_content').html(rte);
}
});
You can see my complete code in action to Jsfiddle.
Thanks very much for your help.
Regards,
Vincent
It’s because you bind the keypress event every time you click on Show.
Try something like this: