Why does this not work?
$( ["blog","user","forum"] ).each(function(num,opt) {
if ( window.location.pathname.indexOf(opt) != -1 ) {
$('#rb-' + opt).attr('checked','checked');
return false;
}
});
When I input $('#rb-blog').attr('checked','checked');
it works as expected?
console.log(typeof opt)
produces string
and the expected value.
--- UPDATE ---
I've just seen the html is being written to the page via ajax and is executed on .ready()
:( Thanks for the help all, much appreciated.