javascript - 隐藏复选框的标签 - Yii2
问题描述
我想知道如何在js中使用hide()隐藏复选框的标签,现在我可以隐藏复选框,但是我试图禁用标签,它不起作用。
<?= $form->field($modelQuestion, "[{$indexQuestion}]justificar_respuesta")->checkbox(array(
'label'=>'',
'labelOptions'=>array('style'=>'padding:5px;'),
))->label('You want a response justified ?');?>
js
解决方案
我不知道 js 这样做有什么意义,但是,您可以这样处理:
id
为您的复选框定义属性:
<?= $form->field($modelQuestion, "[{$indexQuestion}]justificar_respuesta")->checkbox(['id' => 'myId', 'labelOptions' => ['style'=>'padding:5px;']])->label('You want a response justified ?');?>
和 jQuery:
$("label[for='myId']").contents().filter(function(){
return (this.nodeType == 3);
}).remove();
推荐阅读
- python - 如何从循环结果创建一个新的python字典而不覆盖
- python - 在嵌套列表中查找索引
- django - 如果 DEBUG=False,Heroku 构建 django 应用程序不会创建 STATIC_ROOT 目录。为什么,里面发生了什么?
- c# - 我正在尝试将我的 chrome 配置文件与 webdriver 一起使用,但它说它已经附加
- flutter - 在 Flutter 中制作 2x2 网格
- excel - 想要文本框中的向上和向下箭头来更改列表框选择
- python - 如何使用 python 转发 twilio 调用
- angular - Laradock 不观看 Angular ng build --watch
- php - 从自定义挂钩 Directus 更新另一个集合
- django - 在将数据保存到数据库时,一些 html 部分正在丢失