Matthew Vaccaro

Guns, God, Country, and Code
  • Index
  • Blog
  • Snippets
  • Simple jQuery Browser Sniff and Append

    I wanted to add some elements into my DOM for users of browsers which I feel are ‘lacking’. So I went ahead and wrote this small jQuery snippet which allows you to append stuff to your DOM after jQuery sniffs for the browsers version. This one will display an element on all Microsoft browsers less than version 8.0.

    <script type="text/javascript">
    	$(document).ready(function(){
    		var bv = $.browser;
    		if (bv.msie && bv.version.slice(0,3) < "8.0") {
    			$('body').append("ADD THIS TO MY SITE!");
    		}
    	});
    </script>
    Go Back