Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Removing a style?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
kangax  
View profile  
 More options Aug 3 2008, 8:26 pm
From: kangax <kan...@gmail.com>
Date: Sun, 3 Aug 2008 17:26:56 -0700 (PDT)
Local: Sun, Aug 3 2008 8:26 pm
Subject: Re: Removing a style?
On Aug 3, 7:57 pm, "andy.kri...@gmail.com" <andy.kri...@gmail.com>
wrote:

> Is there a way to remove a custom-style set on an element such that
> the element will return to its stylesheet style? For example, on drag-
> and-drop, styles are set on the dragged element and it would be great
> if I could call something like
> element.removeStyle(['opacity','top,...]) to restore the element to
> it's stylesheet style (opacity is easy to reset but there are other
> things like top, left, position for which I'd rather not hard-code
> values).

This is usually done by assigning an empty string to a property, e.g.:

element.style.backgroundColor = '';

As far as `removeStyle` helper, something like this should work:

Element.addMethods({
  removeStyle: function(element) {
    element = $(element);
    $A(arguments).slice(1).each(function(style) {
      element.setStyle({ style: '' })
    });
    return element;
  }

});

// then

$(someElement).removeStyle('color', 'opacity', 'position');

--
kangax


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.