使用jquery添加类

时间:2017-04-12 14:56:20

标签: javascript jquery css

我希望在它的长度等于零时添加带有输入类的附加(我将其删除以进行编辑)但它没有添加类,任何人都可以帮助我

from channels import Group
from channels.generic.websockets import JsonWebsocketConsumer

class MyConsumer(JsonWebsocketConsumer):

    groupname = 'foo'

    def connect(self, message, **kwargs):
        # send an accept or the connection will be dropped automatically
        self.message.reply_channel.send({"accept": True})
        # add the channel to the broadcast group
        Group(self.groupname).add(message.reply_channel)
        # do the rest of logic that should happen on connection established
        ...

    def disconnect(self, message, **kwargs):
        Group(self.groupname).discard(message.reply_channel)
        # do the rest of logic that should happen on disconnect
        ...

这里是html代码

$(document).on('click', '.remove-item', function () {
    if ($('.item-div').length >= 1) {
        $(this).closest('.item-div').remove();
    }
    if($.trim($(".item-div").html())=='')
        {
            alert(1);
            $('#Options').append(
                '<div class="item-div" id="item' + $('.item-div').length + '">'
                + $('.item-div:first').html().replace(/\[0\]/g, '[' + $('.item-div').length + ']').replace(/-0-/g, '-'
                + $('.item-div').length + '-')
                + '</div>'
                );
        }
    return false;
});

0 个答案:

没有答案