I am having trouble applying a style that is !important. I’ve tried:
$(\"#elem\").css(\"width\", \"100px          
        Instead of using the css() function try the addClass() function:
  <script>
  $(document).ready(function() {
    $("#example").addClass("exampleClass");
  });
  </script>
  <style>
  .exampleClass{
    width:100% !important;
    height:100% !important;
  }
  </style>
                                                                        Do it like this:
$("#elem").get(0).style.width= "100px!important";
                                                                        You can do this:
$("#elem").css("cssText", "width: 100px !important;");
Using "cssText" as the property name and whatever you want added to the CSS as its value.
You can set the width directly using .width() like this:
$("#elem").width(100);
Updated for comments: You have this option as well, but it'll replace all css on the element, so not sure it's any more viable:
$('#elem').css('cssText', 'width: 100px !important');
                                                                        If it is not so relevant and since you're dealing with one element which is #elem, you can change its id to something else and style it as you wish...
$('#elem').attr('id', 'cheaterId');
And in your CSS:
#cheaterId { width: 100px;}
                                                                        FYI, it doesn't work because jQuery doesn't support it. There was a ticket filed on 2012 (#11173 $(elem).css("property", "value !important") fails) that was eventually closed as WONTFIX.