Javascript切换类不起作用?

时间:2016-10-22 06:48:25

标签: javascript class toggle this buttonclick

$('.form-control').on('focus blur', function (e) {
    $(this).parents('.form-group').toggleClass('focused', (e.type === 'focus' || this.value.length > 0));
}).trigger('blur');

$('#moveleft').click(function () {
    $('#textbox').animate({
        'marginLeft': "0" //moves left
    });
    $('.toplam').animate({
        'marginLeft': "100%" //moves right
    });
});

$('#moveright').click(function () {
    $('#textbox').animate({
        'marginLeft': "50%" //moves right
    });
    $('.toplam').animate({
        'marginLeft': "0" //moves right
    });
});

1 个答案:

答案 0 :(得分:0)

您正在尝试连接到不存在的“焦点模糊”事件。

.on("focus", function(e) { });

.on("blur", function(e) { } );

https://jsfiddle.net/kt0sswfh/