怎样能让checkbox默认打开或始终打开?

小和尚已还俗 2020-01-01 01:58:07
这是源文件
{if $deductcredit>0}
<div class="fui-cell">
<div class="fui-cell-label" style="width: auto;"> <span id="deductcredit_info" class='text-danger'>{$deductcredit}</span> {$_W['shopset']['trade']['credittext']}可抵扣 ¥<span id="deductcredit_money" class='text-danger'>{php echo number_format($deductmoney,2)}</span> 元</div>
<div class="fui-cell-info"></div>
<span id="deductcredit_money" class='text-danger'><strong>点击开启</strong></span>
<div class="fui-cell-remark noremark"><input id="deductcredit" data-credit="{$deductcredit}" data-money='{$deductmoney}' type="checkbox" class="fui-switch fui-switch-small fui-switch-danger pull-right"></div>
</div>
{/if}
{if $deductcredit2>0}
<div class="fui-cell">
<div class="fui-cell-label" style="width: auto;">{$_W['shopset']['trade']['moneytext']}可抵扣 <span id='deductcredit2_money' class="text-danger">{php echo number_format($deductcredit2,2)}</span>元
{if $include_dispath}<span id="include_dispath">(含运费)</span>{/if}</div>
<div class="fui-cell-info"></div>
<div class="fui-cell-remark noremark info"><input id="deductcredit2" data-credit2="{$deductcredit2}" type="checkbox" class="fui-switch fui-switch-small fui-switch-danger pull-right"></div>
</div>
{/if}

我在type="checkbox"后面加了checked="checked"没用,
加了checked="1"没用,
加了checked="true"也没用
是这个div和这设置有冲突吗
我用的是别人的源码
请教怎么改才行

源文件底部还有一段会不会和这个有影响

{template '_account'}
{template 'sale/coupon/util/picker'}
{if $show_card}
{template 'membercard/picker'}
{/if}
{php $followed = m('user')->followed($member['openid'])}

<script language='javascript'>

//监听浏览器返回上一页
$(function(){
pushHistory();
});
function pushHistory(){
window.addEventListener("popstate", function(e){
$('.invoice-picker').hide();
}, false);
};


var clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
$(window).on('resize', function () {
var nowClientHeight = document.documentElement.clientHeight || document.body.clientHeight;
if (clientHeight > nowClientHeight) {
//键盘弹出的事件处理
var h = document.body.clientHeight;
$('#addaddress .address-alert').removeClass('style1');
$('#addaddress .address-alert').addClass('style2');
}
else {
//键盘收起的事件处理
var h = document.body.clientHeight;
$('#addaddress .address-alert').removeClass('style2');
$('#addaddress .address-alert').addClass('style1');
}
});


$(window).resize(function() {
$('.fui-navbar').css('display', 'block')
});
$(function () {
setTimeout(function () {
var width = window.screen.width * window.devicePixelRatio;
var height = window.screen.height * window.devicePixelRatio;
var h = document.body.offsetHeight * window.devicePixelRatio;
// 微信版本6.6.7
if(h == 1923){
$(".fui-navbar,.cart-list,.fui-footer,.fui-content.navbar").removeClass('iphonex');
return;
}

if(height==2436 && width==1125){
$(".fui-navbar,.cart-list,.fui-footer,.fui-content.navbar").addClass('iphonex')
}
},600)
})
require(['biz/order/address'], function (modal) {
modal.initPost({new_area: {php echo $new_area}, address_street: {php echo $address_street}});
});

require(['biz/order/create'], function (modal) {
modal.init({php echo json_encode($createInfo)},{php echo empty($invoice_arr)?'false':$invoice_arr}||{});


{if !$followed && !empty($share['followqrcode'])&& empty($trade['shop_strengthen'])}
$("#attention").css("display","block");
{/if}

$("#attention-colse").click(function(){
$("#attention").addClass("shut")
setTimeout(function(){
$("#attention").css("display","none")

$("#attention").removeClass("shut")
},1000)
})

$(".back2").click(function(){
$("#giveUp").css("display","block")
})
$("#giveUp .cancel").click(function(){
$("#giveUp").css("display","none")
})

$("#address-colse").click(function(){
$("#addaddress").addClass("shut")
setTimeout(function(){
$("#addaddress").css("display","none")

$("#addaddress").removeClass("shut")
},1000)
})
$("#address-show").click(function(){
$("#addaddress").css("display","block")
})

});</script>
...全文
315 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
代龙涛 2020-01-03
  • 打赏
  • 举报
回复
可能是js定义的自动关闭,去一下class的值或者ID的值调试一下应该就可以找到怎么解决
  • 打赏
  • 举报
回复
加了没用哦,会被刷新掉,打开瞬间打开,马上就自动关闭了
于小九 2020-01-01
  • 打赏
  • 举报
回复
原语句
<input id="deductcredit" data-credit="{$deductcredit}" data-money='{$deductmoney}' type="checkbox" class="fui-switch fui-switch-small fui-switch-danger pull-right">
中新增
checked="checked"
属性可以使勾选框为默认选中状态,以下为补齐修改后的一段
<input id="deductcredit" data-credit="{$deductcredit}" data-money='{$deductmoney}' type="checkbox" class="fui-switch fui-switch-small fui-switch-danger pull-right" checked="checked">

20,396

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧