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 8280377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:39:19+00:00 2026-06-08T09:39:19+00:00

I wrote a Chrome plugin, and I am listening to the ‘DOM ready event’

  • 0

I wrote a Chrome plugin, and I am listening to the ‘DOM ready event’ like this:

$(document).ready(function () {
    //here I select some elements and remove them.
});

Sometimes I cannot get the elements I want, even if they really exist. But when the page is loaded, I open the developer tools and run the same code in console and it works again.

I am confused why I can’t get the elements when the DOM is ready, and the code I write is correct.

  • 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-08T09:39:21+00:00Added an answer on June 8, 2026 at 9:39 am

    Sounds like the elements you are looking for are being added after the DOM is ready.

    Try swaping out your document.ready for the function below.

    $(window).load(function() {
     // executes when complete page is fully loaded, including all frames, objects and images
     alert("window is loaded");
    });
    

    jQuery offers two powerful methods to execute code and attach event handlers: $(document).ready and $(window).load. The document ready event executes already when the HTML-Document is loaded and the DOM is ready, even if all the graphics haven’t loaded yet. If you want to hook up your events for certain elements before the window loads, then $(document).ready is the right place.

    The window load event executes a bit later when the complete page is fully loaded, including all frames, objects and images. Therefore functions which concern images or other page contents should be placed in the load event for the window or the content tag itself.

    Taken from
    http://4loc.wordpress.com/2009/04/28/documentready-vs-windowload/

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

Sidebar

Related Questions

This script I wrote works perfect on IE! It works on Chrome and FireFox
I would like to write a Chrome plugin that will communicate with my native
I wrote a self invoking function in both firefox and chrome it it wouldn't
I wrote this code and it is working nicely in Google Chrome but when
I would like to write a small Google Chrome extension in which I use
This code takes 3 seconds on Chrome and 6s on Firefox. If I write
I wrote a symfony task to fill a database of sample data. Here's a
I wrote a small NPAPI plugin using an old Mozilla NPRuntime example as a
Is it possible to access Google Chrome's cache from within an extension? I'd like
Is this a technology I should spend much time evaluating? http://code.google.com/chrome/chromeframe/ Chrome Frame is

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.