我在.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";
}
}