Search code examples
javascriptjquerycssinsertspiceworks

Class selector returns null when I test


I have a snipper of set html. The basic structure is

<div>
 <div></div>
 <div class="some_class another_class ticket_print_wrapper visible"></div>
</div>

So I am trying to insert another button via code. To do this, I am using(crudely for now):

$(".ticket_print_wrapper").insertAfter("<p>Moo</p>");

There is a jsfiddle here: http://jsfiddle.net/Zmxpt/

It doesn't seem to accept ".ticket_print_wrapper" as an object. Could anyone break my sleepless agony on this one, please?


Solution

  • Use $(".actions").append("<p>Moo</p>"); if you want to add another contenton the same level with two buttons.

    Demo