append() outside or prependTo().next() ?

append() outside or prependTo().next() ?

Assume the following html code:

  1. <table class="foobar">...</table>
  2. <script>....</script>
  3. <script>....</script>
  4. <script>....</script>
  5. <p>.....</p>

Now I want to insert some stuff AFTER table which can be identified by its class.

The two methods I considered do not work:

1. $(".foobar").append("......");

appends something INSIDE the <table>...</table> element but I want it outside

2. $("......").prependTo($(".foobar").next());

does not work either. a pre-grouping of $(".foobar").next() in an enclosing bracket is not correctly recognized.
Or the stuff is inserted into <script> element. But I want it in the next VISIBLE element

Is there another solution?