On Dec 7, 8:34 am, Beginner <pixel.b...@gmail.com> wrote:
> $(document).ready(function(){
>                 $("#XXX").click(function(event){
> document.write("TESTOUTPUT");
>
> }});

> Unfortunately the text "testoutput" will immediately disappear after
> the click event passed. Is there a remedy for that? I need it to
> appear after a click.

The problem is that you can't really use document.write once the
document is closed.  Many people discourage its use entirely.

If you have a certain place you want the output to appear, perhaps in
this tag:

    <p id="outputArea"></p>

Then you can do this:

    $(document).ready(function() {
        $("#XXX").click(function(event) {
            $("#outputArea").text("TESTOUTPUT");
        });
    });

If you don't already have a place in mind, and you just want to append
it to the body, you can do this instead:

            $("<p>TESTOUTPUT</p>).appendTo("body");

Cheers,

  -- Scott

Reply via email to