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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:33:51+00:00 2026-06-04T17:33:51+00:00

I inject a style via javascript in the head of a document in this

  • 0

I inject a style via javascript in the head of a document in this way:

var style = document.createElement("style");
document.head.appendChild(style);
style.innerHTML = "a, .left-hand { cursor:wait; }";

I’d like to know if there’s a way to check if this style is in the document (considering that there others) and how to delete it.

Thanks

  • 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-04T17:33:54+00:00Added an answer on June 4, 2026 at 5:33 pm

    Just keep the reference around, in this case the style variable.

    To check if it’s still in the DOM, check if it has a parent using parentNode. If it does, it’s still in the DOM. If it does not (null), it’s not in the DOM.

    To remove it:

    if(style.parentNode){                     //check if it has a parent
        style.parentNode.removeChild(style);  //if it does, this is how to remove it
    }
    

    Even after this, as long as something still references the style tag, in this case the style variable, you can still reappend it to the DOM. removeChild only removes the element from the DOM, and it does not clear references.

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

Sidebar

Related Questions

right now , I use jQUery(document).ready to inject javascript into a div. All is
I'm trying to add some styles into a page using javascript var style =
Is there a way to inject R code output into the generated document without
is it possible to inject from something like this : public class DomainEntity {
I want to inject dynamically these tags using JavaScript. <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> <meta
I inject html to div on the page (contains float div) var text =
I have some HTML that inject with Javascript into a web page. The final
I'm wondering if it is a good style to inject utility methods with google
I'm building something that is going to inject HTML into a users website via
I have created four ASP.NET Server controls that will inject a lot of JavaScript

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.