我正在使用 jquery-mobile,我对处理组中的复选框有疑问:
我想显示带有复选框的 php 页面,如果该值从数据库中设置为 true,我想在带有 if 条件的复选框组中选中复选框。
喜欢 :
if(foo) {
$(checkbox.id).setChecked
$(checkbox.id).refresh();
}
我正在使用 jquery-mobile,我对处理组中的复选框有疑问:
我想显示带有复选框的 php 页面,如果该值从数据库中设置为 true,我想在带有 if 条件的复选框组中选中复选框。
喜欢 :
if(foo) {
$(checkbox.id).setChecked
$(checkbox.id).refresh();
}
如果你使用php来渲染页面,为什么需要js来勾选复选框?只是做类似的事情
//in your php
while($row){ // assuming $row is your database row
$checked = $row['foo'] == true? 'checked' : '';
echo '<input type="checkbox" '.$checked.' class="my-checkbox" />';
}
//js in your onload event
$('.my-checkbox').each(function(){
if(this.checked){
$(this).refresh();
}
});