0

i have an issue in replacing the class,i want to replace the class using jquery or java script. i need to change the class which is inside the ul tag. how i can change it

 <ul  id="user-listview" class="userlist" data-bind="foreach:Items">
    <li>
   <span id="spname" data-bind="text:userName"  class="c-user"/><span>
   <div>
      <img id="imguser" data-bind="attr: { src:userImageUrl }" class="c-image" />
     </div>
   </li>
  </ul>

 // I am trying like below code but its doesn't work
  $(".userlist li #spname").removeClass('c-user').addClass('IPuser');
  $(".userlist li #imguser").removeClass('c-image').addClass('IPimage');
kitty sarvaj
  • 517
  • 5
  • 10
  • 24

1 Answers1

0
window.document.getElementById("myId").classList.add("myNewClass");

And if you want to remove the previous class:

window.document.getElementById("myId").classList.remove("myOldClass");
xale94
  • 424
  • 5
  • 12