jQuery iff plugin example
jQuery iff plugin example by Adam Schwartz. jQuery iff plugin by http://benalman.com/projects/jquery-iff-plugin/.
by adamschwartz
HTML
<script src="http://benalman.com/code/javascript/jquery/jquery.ba-iff.min.js"></script>
<div>Awesome</div>
<div>Not awesome</div>
JavaScript
//very contrived example, but gets the point accross
$('div').each(function(){
var test = this.innerHTML.match(/not/i);
$(this)
.iff(test)
.css('color', 'red')
.end()
.iff(!test)
.css('color', 'green')
.end()
;
});