Monday 28 November 2011


Set "!important" style by JavaScript

It is very easy to set style in any DOM element by Javascript like:

var target = document.getElementById('MyDiv');
target .style.marginleft ="100px";

But if you want to add "!important" like this -

target .style.marginleft ="100px !important";
this will not work.

Use this code to get it done.
target.setAttribute('style', 'margin-left:200px !important');

11 comments:

  1. It is very helpful. Thank you.

    ReplyDelete
  2. naturally like youг website but yοu neеd
    to taκe a loοk at the spelling on quіte a few of уour ροsts.

    Many of them аre rifе wіth sρelling iѕsues and I to find it verу bothersоme
    to tell the reality neveгtheless Ι'll surely come again again.

    Feel free to visit my web-site ... game.pointblank-kings.com

    ReplyDelete
  3. Αt this time it sounds liκe Wοrԁρress iѕ thе best blogging platform aѵailablе right now.
    (fгom what I've read) Is that what you are using on your blog?

    my web page :: feinz.altervista.org

    ReplyDelete
  4. Hі ωould you mind letting me know ωhich hоsting comρаny yоu're utilizing? I'vе loaded your blog іn 3 different browsеrѕ and I muѕt
    say this blоg loаԁs a lot quiсker
    thеn most. Can you rеcommend a good hosting providеr at a honest ρrice?

    Thanks, I appreсiate it!

    my ωeb page Americas Cardroom Poker Offer

    ReplyDelete
  5. The downside of this method is it overrides all other styles set

    ReplyDelete
  6. Everything said made a bunch of sense. However, consider this,
    what if you added a little information? I mean, I don't want to tell you how to run your blog, but what if you added a post title to possibly grab folk's attention?
    I mean Untitled is kinda vanilla. You could peek at Yahoo's home page and note how they create post headlines to get viewers to click. You might add a related video or a related picture or two to grab readers interested about everything've written.
    In my opinion, it would bring your website a little livelier.


    Feel free to visit my blog Portein Supplmements

    ReplyDelete
  7. Wonderful article! This is the kind of information that are supposed to be shared around the net.
    Disgrace on Google for not positioning this submit higher!
    Come on over and consult with my site . Thanks =)

    Feel free to surf to my blog Cambogia trim review

    ReplyDelete
  8. I delight in, lead to I discovered just what I was looking
    for. You have ended my four day long hunt! God Bless you
    man. Have a nice day. Bye

    my blog; make real money online

    ReplyDelete
  9. Thanks for sharing your thoughts about diet pills. Regards

    my website: acai ultra lean

    ReplyDelete
  10. Hey there just wanted to give you a brief heads up and let you know a few
    of the pictures aren't loading properly. I'm not sure why but I
    think its a linking issue. I've tried it in two different internet browsers and both show the same outcome.


    loss weight now

    ReplyDelete
  11. Good day I am so happy I found your website, I really found you by accident,
    while I was browsing on Aol for something else, Regardless I
    am here now and would just like to say kudos for a tremendous post and
    a all round enjoyable blog (I also love the theme/design), I don’t have time to
    read it all at the minute but I have book-marked
    it and also included your RSS feeds, so when I have time I will be back to read more, Please do keep up the fantastic b.



    Also visit my blog :: Diet Patch Review

    ReplyDelete