Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Prepending HTML using JavaScript

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #256719
    ChristianSirolli
    Participant

    I want to prepend a disclaimer above the ads on my website. The host I am using makes it impossible to edit the HTML source to add it. The text I am working with includes the use of both a paragraph tag and an anchor tag. I would prefer to use only JavaScript, as the host doesn’t seem to do well with JQuery. Is there a way to prepend HTML text only using JavaScript?

    #256733
    JeroenR
    Participant

    Look here for an example how to insert an element before others: https://codepen.io/jeroenreijs/pen/NgeaXJ

    #256738
    ChristianSirolli
    Participant

    How can I include styling with that? Is there a way I can include an ID or a Class or even style it inline?

    #256743
    JeroenR
    Participant

    You can use setAttribute() for that. I have changed the pen. For example: p.setAttribute('id','yourid');.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.