Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:21:18+00:00 2026-06-04T04:21:18+00:00

I want to add an element after every like button (chrome extension). Since posts

  • 0

I want to add an element after every “like” button (chrome extension). Since posts are added to the news feed without refreshing the page, I have to add an event listener “DOMNodeInserted“. But when I try to put the after() function inside it, it doesn’t work.

Code:

    $("#contentArea").addEventListener("DOMNodeInserted", function(event) {
        $(".like_link").after('<span class="dot"> · </span><button class="taheles_link stat_elem as_link" title="תגיד תכל&acute;ס" type="submit" name="taheles" onclick="apply_taheles()" data-ft="{&quot;tn&quot;:&quot;&gt;&quot;,&quot;type&quot;:22}"><span class="taheles_default_message">תכל&acute;ס</span><span class="taheles_saving_message">לא תכלס</span></button>');
        $(".taheles_saving_message").hide(); 
    });

When I change $("#contentArea") to document it crashes all the page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:21:18+00:00Added an answer on June 4, 2026 at 4:21 am

    if you want to add an event listener in jQuery, that is not the method, the corect way should always be:

    $(document or window).bind( your_event_name, function(event) { your_callback });
    

    with this in mind, you can write:

    $(document).bind('DOMNodeInserted', function(event) {
    
        alert('inserted ' + event.target.nodeName + // new node
              ' in ' + event.relatedNode.nodeName); // parent
    
    });
    

    or do what you need to perform every time a node is inserted in the DOM.


    for your information, if you want to use addEventListener you need to use plain javascript and not jQuery.

    document.addEventListener("DOMNodeInserted", function () {
        // your code
    }, false);
    

    Edit: As on jQuery 1.7, please use the ‘.on’ function instead: http://api.jquery.com/on/


    another error that comes up of your method (if it worked) is that you will break your application as you are inserting a node and call the DOMNodeInserted (cause you have inserted a node) and that will insert the node again, and call the DOMNodeInserted again…

    you can see what is going on …

    I would suggest that you listen to the correct method and append your span there…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a hidden input after some element. I am using this
I want to add two HTML elements to a Dom element one after another.
I want to add style in ASP.NET textbox control. I couldn't find textbox element
I want to add elements to arrays within an object that I access like
I want to write an extension for Google chrome that detects snippets of source
I want to add elements after last child in the XML. But I got
I want to add an XML fragment to the last element to an XML
when i use append it add an element WITHIN an element. i want to
I have a certain textbox and I want to add a div after it.
I want to hide a DIV element after the previous effects/movements have completed. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.