185
rated 0 times
[
190]
[
5]
/ answers: 1 / hits: 11321
/ 10 Years ago, thu, april 10, 2014, 12:00:00
I have an html element like this:
<dd><span class=label label-success id=status>Production</span></dd>
I want to change it to
<dd><span class=label label-warning id=status>Idle</span>
based on a ws.socket message.
setTimeout(function(){
window.ws = new WebSocket('ws://localhost:8088/sock/123');
window.ws.onmessage = function (evt) {
field.value = Idle
};
window.ws.onclose = function (evt){
}
window.ws.onopen = function (evt){
}
}, 500);
I want to change the value from Production to Idle and the class to label label-warning.
I know to change the value I would do this:
var field = document.getElementById(status)
but I'm not exactly sure how to change the class and would using field.value be the correct way to change a span text?
More From » jquery