我试图根据一个按钮是否是活动的(选中的)来划分出一个div。当我选择切换键时,js似乎在触发,尽管div并没有消失。
细长模板
- @products.each do |product|
.mdl-cell.mdl-cell--4-col.item-border.mdl-shadow--2dp
.mdl-cell.mdl-cell--1-col.mdl-cell--10-offset
label.mdl-switch.mdl-js-switch.mdl-js-ripple-effect for=product.name
input.mdl-switch__input checked="checked" type="checkbox" id=product.name /
span.mdl-switch__label
.mdl-cell.mdl-cell--12-col
h4.teal-heading= product.name
- @properties.each do |property|
.mdl-cell.mdl-cell--12-col
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--12-col
input.mdl-textfield__input type="text" id=property.id
label.mdl-textfield__label for=property.id
= "#{property.name } Price"Jquery
$('.mdl-switch__input').click(function(){ $(this).parent('.mdl-cell--4-col').$(this).fadeTo(500, 0.2); });发布于 2016-12-11 14:04:41
我认为这应该能起作用。
$('.mdl-switch__input').click(function() {
$(this).closest('.mdl-cell--4-col').fadeTo(500, 0.2);
});https://stackoverflow.com/questions/41086753
复制相似问题