sndu sndu - 1 year ago 115
HTML Question

How to change the displayed value when the view is clicked?

I have this notification list which I have created using HTML and Thymeleaf. Here I am displaying the number of notifications using

${#lists.size(notifications)}
which displays the value properly.

<li class="dropdown messages-menu">
<a id="notification-href" href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i>
<span class="label label-success"><span id ="notification-count" th:text="${#lists.size(notifications)}"></span></span>
</a>
...........


Once I have clicked the notification list, I want to change the notification count to zero. For this I have wrote following function.

$(document).ready(function(){
$("#notification-href").click(function(){
$("#notification-count") == 0;
});
});


This function does not work and I see no errors or exceptions either. Can anyone tell what is wrong here?

Answer Source

You should use something like this:

$("#notification-count").text('0')

// or

$("#notification-count").html('0');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download