Created
August 5, 2014 09:52
-
-
Save devcem/a1a85a9e9473e48a24d0 to your computer and use it in GitHub Desktop.
Optimization for Jquery Hide & Show functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var displayDump = Array(); | |
$.fn.hide = function() { | |
var selector = this.selector; | |
displayDump[selector] = Array(); | |
$(this).each(function( index ) { | |
displayDump[selector].push($(selector)[index].innerHTML); | |
$(this).css("display","none").html(""); | |
}); | |
}; | |
$.fn.show = function() { | |
var selector = this.selector; | |
for(i=0;i<displayDump[selector].length;i++){ | |
$(selector).html(displayDump[selector][i]); | |
} | |
$(this).each(function( index ) { | |
$(this).css("display","block"); | |
$(this).html(displayDump[selector][index]); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use it same functions
$(obj).hide() or show()