Modernizr test

This is a simple example of Modernizr. Note that it use the developement version of Modernizr which include ALL the tests supported by Modernizr.

HTML

<script src="http://modernizr.com/downloads/modernizr-2.5.3.js"></script>
<div id="what">Well... I'm not sure.</div>

CSS

/**
 * By default, everything is black & white
 */
#what {
    padding : 2em;
    margin  : 2em;
    text-align : center;
    
    border : 1px solid #000;
}

/**
 * What is shown depend on the browser capacity.
 */
.rgba #what {
    border-color : green;
    color : green;
}

.no-rgba #fail {
    border-color : red;
    color : red;
}

JavaScript

if(Modernizr.hasEvent('touchstart') || navigator.userAgent.search(/Touch/i) != -1){
     alert("is touch");
        return true;
    }else{
        alert("is not touch");
        return false;
    }