我有一个无线电组,它正在动态地来到我的页面。我能够成功地禁用任何使用php的无线电,但我想添加css属性的文本-装饰:行上禁用的无线电标签。这是代码:
<div class="form-item form-type-radio form-item-example-pane-time-slot-1">
<input type="radio" id="edit-example-pane-time-slot-1-11" name="example_pane[time_slot_1]" value="11" class="form-radio">
<label class="option" for="edit-example-pane-time-slot-1-11">11 - 12 pm </label>
</div>
如何使用jquery?我的jquery代码如下:
if ($('#edit-example-pane-time-slot-1-11').attr('disabled',true))
{
$(this).css('text-decoration', 'line-through');
}
而且不起作用。
发布于 2014-08-25 18:27:45
你只需使用css就可以做到这一点。
.form-radio:disabled + .option {
text-decoration: line-through;
}
小提琴
发布于 2014-08-25 17:50:33
你应该检查一下
if ($('#edit-example-pane-time-slot-1-11').attr('disabled')===true))
{$(this).siblings('label').css('text-decoration', 'line-through');}
或者只是禁用它,您应该使用.attr('disabled','disabled')
。看来你把这两个人混在一起了。
PS:请阅读==和===在JavaScript中的区别。
发布于 2014-08-25 17:52:57
下面是为它添加css的代码。
$(this).siblings('label').css('text-decoration','line-through');
https://stackoverflow.com/questions/25491544
复制相似问题