使用jquery单击时删除class / CSS图标

时间:2014-08-26 10:17:08

标签: jquery

以下是我的代码。我想删除课程" fa-circle"每当我点击链接。 " fa-circle"是一个CSS图标。如何使用jquery实现这一目标?谢谢

<tr id="message1">
            <td class="padding-none">
                <a href="#" class="list-group-item" style="display:block;word-wrap:break-word; cursor:pointer;" onclick="getmail(<?= $row_msg['mailbox_id'] ?>);">
                    <span class="label label-inverse pull-right"><?= date('d M' ,strtotime($row_msg['sent_on'])) ?></span>
                    <h4><?= $subject ?> <i class="fa fa-circle text-primary"></i></h4>
                    <p class='text-regular margin-none' style="height:40px; overflow:hidden;"><?= $row_msg['email_body']; ?></p>
                </a>
            </td>
        </tr>
    <tr id="message2">
        <td class="padding-none">
            <a href="#" class="list-group-item" style="display:block;word-wrap:break-word; cursor:pointer;" onclick="getmail(<?= $row_msg['mailbox_id'] ?>);">
                <span class="label label-inverse pull-right"><?= date('d M' ,strtotime($row_msg['sent_on'])) ?></span>
                <h4><?= $subject ?> <i class="fa fa-circle text-primary"></i></h4>
                <p class='text-regular margin-none' style="height:40px; overflow:hidden;"><?= $row_msg['email_body']; ?></p>
            </a>
        </td>
    </tr>

这是我的getmail功能

function getmail(mailno){
    $('#mailbox').show(400);
    $.ajax({
        type: "POST",
        url: "../ajax/getmail.php",
        data: "mailno="+mailno,
        dataType: 'json',
        success: callbackGetMail
    });
}

1 个答案:

答案 0 :(得分:1)

使用某个选择器选择锚点,然后对类.removeClass()的子项使用fa-circle方法。

<a href="#" data-mailboxid="<?= $row_msg['mailbox_id'] ?>" class="list-group-item" style="display:block;word-wrap:break-word; cursor:pointer;">

$('a').click(function(event) {
    event.preventDefault();
    getmail($(this).data("mailboxid"));
    $(this).find('.fa-circle').removeClass('fa-circle');
});
相关问题