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,890
  • 2
  • 24
  • 32
Vikram Anand Bhushan
  • 4,636
  • 14
  • 57
  • 124
  • 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,377
  • 15
  • 52
  • 68
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,021
  • 8
  • 44
  • 66
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
  • 129,808
  • 12
  • 152
  • 166