Javascript 通过JQuery更改类不处理Websocket消息

Javascript 通过JQuery更改类不处理Websocket消息,javascript,jquery,spring,thymeleaf,spring-websocket,Javascript,Jquery,Spring,Thymeleaf,Spring Websocket,我在一个小问题上陷入困境已有一段时间了。我通过stomp客户端设置了spring WebSocket,我收到消息并尝试对特定元素调用简单的removeClass()/addClass()/css()操作 以下是相关代码: // Function called on page load function connectToConfirm() { var sck = new SockJS('/endpoint'); sClient = Stomp.over(sck); sC

我在一个小问题上陷入困境已有一段时间了。我通过stomp客户端设置了spring WebSocket,我收到消息并尝试对特定元素调用简单的removeClass()/addClass()/css()操作

以下是相关代码:

// Function called on page load
function connectToConfirm() {
    var sck = new SockJS('/endpoint');
    sClient = Stomp.over(sck); 
    sClient.connect({}, function(frame) {
        console.log('Connected: ' + frame);
        sClient.subscribe('/test', function(readyConfirmation) {
            setReady(JSON.parse(readyConfirmation.body));
        });
    });
}

function setReady(content) {
    $('#readyIndicator-'+content.id)
        .addClass('fa-check')
        .removeClass('fa-times')
        .css('color', 'green');
    console.log("ID: " +content.id); 
    // Displays the correct id and shows the function gets called
    console.log("Object exists?: " +$('#readyIndicator-'+content.id).length);
    // Displays "1", therefore an element by that id exists.

}
带有Thymeleaf的HTML${group}对象通过HandlerInterceptorAdapter实现添加,并且正确显示值:

<tr th:each="user: ${group.members}">
    <td width="80%" th:text="${user.username}">Username</td>
    <td width="20%">
        <i th:id="readyIndicator- + ${user.id}" class="fa fa-times"
                                style="color: red;"></i>
    </td>
</tr>
。。我得到的答复是:

<<< MESSAGE
destination:/test
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:ffbazdj4-82
content-length:84

{"id":"123", .. , ..}

<<< MESSAGE
destination:/test
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:ffbazdj4-82
content-length:84

{"id":"123", .. , ..}