Created
February 15, 2012 17:07
-
-
Save dfadler/1837359 to your computer and use it in GitHub Desktop.
Before and after for IE7
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
// Appends a div to the passed object(s) | |
function appendToObject(obj) { | |
if(typeof(obj) === 'object') { | |
for(var i = 0; i <= obj.length; i ++) { | |
$(obj[i]) | |
.append('<div class="after">.</div>'); | |
} | |
} else { | |
$(obj) | |
.append('<div class="after">.</div>'); | |
} | |
} | |
// Prepend a div to the passed object(s) | |
function prependToObject(obj) { | |
if(typeof(obj) === 'object') { | |
for(var i = 0; i <= obj.length; i ++) { | |
$(obj[i]) | |
.prepend('<div class="before">.</div>'); | |
} | |
} else { | |
$(obj) | |
.prepend('<div class="before">.</div>'); | |
} | |
} | |
// Needed to attach before and after divs in IE7 | |
// Assumes the use if HTML5 Boilerplate | |
if($('html').hasClass('lt-ie8')) { | |
var prependTo = ['element', 'element'], | |
appendTo = ['element', 'element']; | |
prependToObject(prependTo); | |
appendToObject(appendTo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment