为什么这不起作用?
$( ["blog","user","forum"] ).each(function(num,opt) {
if ( window.location.pathname.indexOf(opt) != -1 ) {
$('#rb-' + opt).attr('checked','checked');
return false;
}
});
当我输入$('#rb-blog').attr('checked','checked');
它按预期工作?
console.log(typeof opt)
产生string
和期望值。
- - 更新 - -
我刚刚看到 html 正在通过 ajax 写入页面并在.ready()
:( 感谢大家的帮助,非常感谢。