改变计数器后改变颜色

时间:2016-02-17 14:30:00

标签: javascript java jsp

我在.JSP文件中有以下元素

<h:commandLink value="#{g_msgs.newIncoming} (#{notify.acknowledgedCounter}) "  
id="counter"
rendered="#{(mainPage.user) !=null}"
action="#{menu.selItemForNewIncoming}"
style="padding-right:15px"
/>   

当计数器改变值

时,我想将计数器的颜色设置为红色

P.S。使用ajax poll每隔5秒检查一次此计数器

here is the ajax poll
<a4j:poll id="poll" interval="5000" reRender="counter" rendered="#{(mainPage.user) !=null}" action="#{notify.loadNea}" oncomplete="clickNotification('#{rich:clientId('showNotificationLink')}')" />

我在javascript中试过这个

document.getElementById(counter).onchange = function(){checkCounter()};

function checkCounter(){
    var counter = document.getElementById(counter).value;
    if(counter == 'true'){
      counter.style.color = "red";
    }
}

0 个答案:

没有答案
相关问题