jQuery's hide() and show() slow in Chrome
var $cssSelector = "display"; | |
var $hideCSS = "none"; | |
var $showCSS = "block"; | |
if ($.browser.chrome) { | |
$cssSelector = "margin-top"; | |
$showCSS = "0"; | |
$hideCSS = "-10000px"; | |
} | |
$("#element").css($cssSelector, $showCSS); // For showing | |
$("#element").css($cssSelector, $hideCSS); // For hiding |
(function($) { | |
var userAgent = navigator.userAgent.toLowerCase(); | |
$.browser = { | |
version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], | |
chrome: /chrome/.test( userAgent ), | |
safari: /webkit/.test( userAgent ), | |
opera: /opera/.test( userAgent ), | |
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), | |
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) | |
}; | |
})(jQuery); |
$element.css('margin-top', '0'); // For showing | |
$element.css('margin-top', '-1000000px'); // For hiding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment