Cannot replace class on the fly from localStorage in jQuery RSS Feed

前端 未结 1 1187
一整个雨季
一整个雨季 2021-01-27 08:39

I\'m trying to fill RSS feed with add to fav utility using jQuery and HTML5 localStorage. What I\'m trying to achieve is when a user clicks on glyphicon-star-empty

1条回答
  •  囚心锁ツ
    2021-01-27 08:58

    Add a change like this inside the for loop,Basically you need to loop over each list element as well as for loop over the array to set it.

       $( ".panel-heading" ).each( function( index, element ){                   
                       if($(this).text() == arr[i].title.trim()){                                            
                           $(this).next().removeClass('glyphicon-star-empty');
                           $(this).next().addClass('glyphicon-star');
    
                       }
    
              }); 
    

    Here is a modified JSfiddle https://jsfiddle.net/ehqefk6j/2/

    0 讨论(0)
提交回复
热议问题