Reputation: 55
I want to know how to hide the label of a check box using hide () in js, now I can hide the check box, but I tried to disable the tag and it does not work.
<?= $form->field($modelQuestion, "[{$indexQuestion}]justificar_respuesta")->checkbox(array(
'label'=>'',
'labelOptions'=>array('style'=>'padding:5px;'),
))->label('You want a response justified ?');?>
js
Upvotes: 0
Views: 1832
Reputation: 533
I don't know what is the point of doing so by js, but, this is how you can handle it:
Define id
attribute for your checkbox:
<?= $form->field($modelQuestion, "[{$indexQuestion}]justificar_respuesta")->checkbox(['id' => 'myId', 'labelOptions' => ['style'=>'padding:5px;']])->label('You want a response justified ?');?>
And jQuery:
$("label[for='myId']").contents().filter(function(){
return (this.nodeType == 3);
}).remove();
Upvotes: 1