weixin_33739646 2014-09-16 23:25 采纳率: 0%
浏览 10

用新数据突出显示div [关闭]

Closed. This question needs to be more focused. It is not currently accepting answers.
                </div>
            </div>
        </div>
                <hr class="my12 outline-none baw0 bb bc-powder-2">
            <div class="grid fw-nowrap fc-black-600">
                    <div class="grid--cell mr8">
                        <svg aria-hidden="true" class="svg-icon iconLightbulb" width="18" height="18" viewbox="0 0 18 18"><path d="M9.5.5a.5.5 0 0 0-1 0v.25a.5.5 0 0 0 1 0V.5zm5.6 2.1a.5.5 0 0 0-.7-.7l-.25.25a.5.5 0 0 0 .7.7l.25-.25zM1 7.5c0-.28.22-.5.5-.5H2a.5.5 0 0 1 0 1h-.5a.5.5 0 0 1-.5-.5zm14.5 0c0-.28.22-.5.5-.5h.5a.5.5 0 0 1 0 1H16a.5.5 0 0 1-.5-.5zM2.9 1.9c.2-.2.5-.2.7 0l.25.25a.5.5 0 1 1-.7.7L2.9 2.6a.5.5 0 0 1 0-.7z" fill-opacity=".4"></path><path opacity=".4" d="M7 16h4v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-1z" fill="#3F3F3F"></path><path d="M15 8a6 6 0 0 1-3.5 5.46V14a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-.54A6 6 0 1 1 15 8zm-4.15-3.85a.5.5 0 0 0-.7.7l2 2a.5.5 0 0 0 .7-.7l-2-2z" fill="#FFC166"></path></svg>
                    </div>
                <div class="grid--cell lh-md">
                    <p class="mb0">
                        <b>Want to improve this question?</b> Update the question so it focuses on one problem only by <a href="/posts/25879928/edit">editing this post</a>.
                    </p>
                    <p class="mb0 mt6">Closed <span title="2014-09-17 12:33:06Z" class="relativetime">5 years ago</span>.</p>
                </div>
            </div>
    </aside>

I've been looking around the net for answers on how you could show new content under a different coloured div and then when the user has clicked on that div it changes to the original set one. So you can tell the difference of whether its been seen or unseen.

Is this done with jquery alone, or does a database and php come into play? I have done some research, and I haven't found anything. So come to ask the experts in hope it may help somebody else.

So as a thought

if(message_status=1){
show new data coloured div
}else if(message_status=2){
show normal coloured div
}
</div>
  • 写回答

1条回答 默认 最新

  • weixin_33676492 2014-09-16 23:41
    关注

    Well, more details would be needed to understand fully answer your question, but your sudo code is basically there.

    //get data
    var getData = $.ajax("your/endpoint", {your: params});
    var NEW_MSG_COLOR = "#CCCCCC";
    var DEFAULT_MSG_COLOR = "#FFFFFF";
    
    getData.then(function (res) {
        //lets assume that the result of getting the data 
        //is an array of message objects
        $.each(res, function (msgIdx, msg) {
            var $div = $("<div />").text(msg.text);
            $div.css("backgroundColor", msg.status === 1 ? NEW_MSG_COLOR : DEFAULT_MSG_COLOR);
            $div.click(function () {
                $div.css(backgroundColor: DEFAULT_MSG_COLOR);
            });
    
            //do something with $div here, stick it in the page, etc...
        });
    });
    

    That should get you most of the way there. The $.ajax assumes that you'll be doing an ajax call to get data somehow, but that's up to you (database, flat files, whatever...)

    评论

报告相同问题?

悬赏问题

  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题