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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:28:13+00:00 2026-05-23T11:28:13+00:00

A jQuery plugin is applying an inline style ( display:block ). I’m feeling lazy

  • 0

A jQuery plugin is applying an inline style (display:block). I’m feeling lazy and want to override it with display:none.

What’s the best (lazy) way?

  • 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-05-23T11:28:14+00:00Added an answer on May 23, 2026 at 11:28 am

    Update: while the following solution works, there’s a much easier method. See below.


    Here’s what I came up with, and I hope this comes in handy – to you or anybody else:

    $('#element').attr('style', function(i, style)
    {
        return style && style.replace(/display[^;]+;?/g, '');
    });
    

    This will remove that inline style.

    I’m not sure this is what you wanted. You wanted to override it, which, as pointed out already, is easily done by $('#element').css('display', 'inline').

    What I was looking for was a solution to REMOVE the inline style completely.
    I need this for a plugin I’m writing where I have to temporarily set some inline CSS values, but want to later remove them; I want the stylesheet to take back control.
    I could do it by storing all of its original values and then putting them back inline, but this solution feels much cleaner to me.


    Here it is in plugin format:

    (function($)
    {
        $.fn.removeStyle = function(style)
        {
            var search = new RegExp(style + '[^;]+;?', 'g');
    
            return this.each(function()
            {
                $(this).attr('style', function(i, style)
                {
                    return style && style.replace(search, '');
                });
            });
        };
    }(jQuery));
    

    If you include this plugin in the page before your script, you can then just call

    $('#element').removeStyle('display');
    

    and that should do the trick.


    Update: I now realized that all this is futile.
    You can simply set it to blank:

    $('#element').css('display', '');
    

    and it’ll automatically be removed for you.

    Here’s a quote from the docs:

    Setting the value of a style property to an empty string — e.g. $('#mydiv').css('color', '') — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery’s .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element.

    I don’t think jQuery is doing any magic here; it seems the style object does this natively.

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

Sidebar

Related Questions

When writing a new jQuery plugin is there a straightforward way of checking that
Is there any jquery plugin for implementing iGoogle style dashboard? So basically drag n
I found this jquery plugin which does exactly what I need, but I want
I am working with jQuery UI Sortable plugin, and applying it to a table.
The jQuery plugin cycle looks for elements of class slideshow . I want to
I added the jQuery plugin smoothdivscroll to a block, it's works though it is
Say I have a jQuery plugin like $.abc = function() {}. Now I want
This was the original division: after applying jquery cycle plugin the image gets out
Using jQuery plugin jEditable. Problem I'm having is that I want whatever is editable
I am writing a jQuery plugin and I am at the optimization stage. I

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.