简体   繁体   English

如何获得这项工作Div addClass

[英]How to get this work Div addClass

I try to make this work but not luck yet, why the DIV does not highlight(Flashing) when the figures updated in stats.php? 我尝试使此工作正常进行,但还不走运,为什么当stats.php中的数字更新时DIV不突出显示(闪烁)?

In stats.php 在stats.php中

<div id="student_today"><b>$<?php print getTodayStats($collageid); ?></b></div>
Month:
<div id="student_month"><b>$<?php print getMonthStats($collageid); ?></b></div>

Below style for div: 以下div样式:

.stats_highlight{
background: #03B1EE;
border-top-color: #03B1EE;
z-index: 10;
color: #fff;

In main.php : 在main.php中:

                      <tr class="live">
                    <td width="267">
                      <p align="left">Today's Students:</p></td>
                    <td width="201">
                      <p align="left">&nbsp;</p></td>
                    <td width="220">
                      <span value="value" id="student_today"></span></td>
                  </tr>
                  <tr class="live">
                    <td width="267">
                      <p align="left">Month's students:</p></td>
                    <td width="201">
                      <p align="left">&nbsp;</p></td>
                    <td width="220">
                      <span class="value" id="student_month"></span></td>
                  </tr>

I need someone who can guide me solve this question. 我需要一个可以指导我解决这个问题的人。 Really appreciate. 万分感激。

Your question: 你的问题:

hello, someone here can guide me how to get javascript addClass in ? 您好,这里有人可以指导我如何获取javascript addClass吗?

The answer using jQuery: 使用jQuery的答案:

$('#test').click(function(){
  $(this).addClass('newClass').removeClass('initialClass');
});

​See DEMO . 参见演示

You will need to click on 'Some text here' (SPAN content); 您将需要单击'Some text here' (SPAN内容); than jQuery will replace initialClass with newClass . jQuery将用newClass代替initialClass。 .. ..

EDIT: 编辑:

Below is for your initial question (in regards with your comments): 以下是您的第一个问题(关于您的评论):

Live demo 现场演示

Now, that was in case you needed to fade out; 现在,以防您需要淡出。 replace the class and fade in. If you need it without class replacement than it would be even with less code. 替换类并淡入。如果不需要类替换,则需要的代码甚至更少。 Please feel free to play with the demo. 请随时试用该演示。

I may have over cooked it ,but this will work 我可能已经煮熟了,但是可以

setTimeout(function(){
                        $("#messagebox").fadeIn("slow", function () {
                        $("#messagebox").addClass("messageboxcss");
                        });
                        }, 1000); 


setTimeout(function(){
                        $("#messagebox").fadeOut("slow", function () {
                        $("#messagebox").removeClass("messageboxcss");
                        });
                        }, 2000); 

JSFIDDLE 的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM