another problem with list
Hi there, hope you got an amazing christmas gift. this is my problem:
I have a year list, when I click on an element of list, I send the data by ajax to php, and refresh the page with new data. this is working perfetcly.
On my list I start with a simbol near the current year. If I click on different year I would that the simbol apper only in the year that I clicked.
I can't achive this.
- <ul class="dropdown-menu">
- <li class="header">Esercizio Contabile</li>
- <li class="esercizio">
- <a href="#">
- <i class="fa text-aqua"></i> 2018
- </a>
- </li>
- <li class="esercizio">
- <a href="#">
- <i class="fa text-aqua"></i> 2017
- </a>
- </li>
-
- </ul>
jquery code:
- $(function(){
- var current_year = (new Date).getFullYear();
- var year;
- $( "li.esercizio" ).each(function( index ) {
- year = $( this ).text();
- if (year===current_year){
- $(".dropdown-menu .fa-check-circle").removeClass("fa-check-circle");
- $(this).find('i').addClass('fa-check-circle');
- }
-
- });
-
- $('.esercizio').click(function(){
-
- year = $(this).text();
-
- $.ajax({
- headers:{
- 'X-CSRF-Token':$('meta[name="_token"]').attr('content')
- },
- type:'post',
- url : 'eserciziofiscale',
- data:{anno:year},
- dataType: "text",
- success: function(data){
-
- $( "li.esercizio" ).each(function( index ) {
- var value = $(this).text();
-
- if (year===value){
- $(".dropdown-menu .fa-check-circle").removeClass("fa-check-circle");
- $(this).find('i').addClass('fa-check-circle');
- }
-
- });
-
- window.location.replace('dashboard');
-
- }
- });
-
-
- });
- });
Thanks for help