Search code examples
javascriptjquerycsspre

Adding pre tag after onload doesn't take effect


I am trying an Jquery plugin for drawing arrows, as described here

The plugin causes this code

<pre class="arrows-and-boxes"> (Src) > (Target) </pre>

to look like this : Src --> Target

If I invoke this code before onload function, it works fine. But after(or within) the onload function, the format doesn't apply.

$("#canvas").append("<pre class=\"arrows-and-boxes\"> (Src) > (Target) </pre>");

I have raised the same question here as well.


Solution

  • The plugin creates a jQuery function called .arrows_and_boxes(). If you call this on the newly created element it should work:

    var $newPre = $("<pre class=\"arrows-and-boxes\"> (User) > (Admin) </pre>");
    $("#canvas").append($newPre)
    $newPre.arrows_and_boxes();
    

    Fiddle Here: http://jsfiddle.net/1p7hz799/3/