Search code examples
javascripthtmlprototypejs

How do I insert content after a block of text using prototype.js?


I am trying to insert a block of html code using prototype.js

I have been able to do this when I target an html element such as

$('footer').insert({top: '<div id="footer_inner"><small>CompanyName, LLC</small></div>'})

Is it possible to inset a div after text such as

James McCarthy (level3)

Is it possible to target the text level3? and insert a block html after it?

Thanks in advance


Solution

  • Sure. Just use after as the first parameter for insert():

    $('level3').insert({after: '<p>HTML goes here</p>'});