切换两个箭头的颜色

toggle the colors of two arrows

本文关键字:颜色 两个      更新时间:2023-09-26

我有看起来像这样的代码,https://jsfiddle.net/mdwxbppd/

<span class="glyphicon glyphicon-triangle-top col-md-12" aria-hidden="true"></span><br />
<span class="col-md-12" style="height: 1px; font-family: 'Passion One', cursive; bottom: 10px; padding-left: 0.01em;">
    <h4 id="vote_count_{{ post.slug }}">
        {{ post.get_vote_count }}
    </h4>
</span><br>
<span class="glyphicon glyphicon-triangle-bottom col-md-12" aria-hidden="true"></span>

我正在尝试实现按钮在单击每个按钮时切换颜色。我试过了,但是每当我刷新页面时,颜色都会恢复到原始颜色,直到我单击其他箭头(因为它们切换)。任何帮助将不胜感激。

这是我尝试过的:

<script>
$(document).ready(function(){
    $('.glyphicon').click(function(){
        $('.glyphicon').css('color', '#333');
        $(this).css('color', '#10fd01');
    });
});
</script>

我不确定,这就是你要找的,但如果是,请尝试以下操作:

$(document).ready(function(){
    if($.cookie("arrow1")){
         //$('#arrow1').toggleClass... or whatever
    }
    $('span.glyphicon').click(function(e){
        $.cookie(e.target.id, true);
        //e.target.toggle class, e.target.style.color =... or whatever
    });
});