jQuery cssText Helps You Improve Browser Reflows

cssText

You know you can manage to redraw an element with single browser reflow. Instead of using .style.property … you can simply add all CSS properties you’d like to change with simply appending to style.cssText property.

var csstxt = $('#selector').css('cssText') + ';top:100;left:100;border:1px solid red;color:#f00;';
$('#selector').css('cssText', csstxt);

That code is a replacement for

$('#selector').css({
   left : '100px',
   top : '100px',
   border : '1px solid red',
   color : '#f00'
});

enjoy!

Related posts:

  1. cssText and how it can be very very useful
  2. jQuery CSS selectors. Change one or more CSS properties!
  3. JQuery ajax script call
This entry was posted in javascript, snippets and tagged , , , , . Bookmark the permalink.

2 Responses to jQuery cssText Helps You Improve Browser Reflows

  1. self fish says:

    cool, dude

  2. julio says:

    nice work

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">