1

I know this is very silly question but I am stuck . I have been trying to add the position:absolute !important using JQUERY function .CSS() but I found out that it is not happening .

my script is something like this .

$(document).ready(function(){
    var winSize = $('#outerPage').height();
    alert(winSize);
     setTimeout(function () {
    //$('#at4m-mobile-container').addClass('bottom');
    $('body div.at4m-dock').css("top",winSize);
    $('body div.at4m-dock').css({"position":"absolute","font-size":"200% !important"});
    $('body div.at4m-dock-toggle').css("top",winSize);
    }, 7500);  

});

Please give me some suggestion

Thanks and regards

Kunj
  • 1,980
  • 2
  • 22
  • 34
Vikram Anand Bhushan
  • 4,836
  • 15
  • 68
  • 130
  • 2
    Have a look here http://stackoverflow.com/questions/2655925/apply-important-css-style-using-jquery Seems to have quite a few different answers for your question. – Lloyd Erasmus Jul 07 '14 at 13:27

3 Answers3

3

jQuery is not understanding the !important attribute.

You can use attr()

Try:

 $('body div.at4m-dock').attr('style', 'font-size: 200% !important;position:absolute !important;');

DEMO

laaposto
  • 11,835
  • 15
  • 54
  • 71
1

Use as, as per my understanding you can not use as "font-size":"200% !important" in %

  $('body div.at4m-dock').css({"position":"absolute!important","font-size":"22px !important"});
Amit
  • 15,217
  • 8
  • 46
  • 68
1

!important is not supported by jQuery.

Also .css() function add inline style so you don't need !important. So you should simply remove it.

Satpal
  • 132,252
  • 13
  • 159
  • 168