AwadGorg
1 month ago

Coverting from jquery to javascript

Posted 1 month ago by AwadGorg

Hello I have this code in jquery and I want to cover it to pure javascript cuz does not make any sense for me to use 80k liberty to just make a small task can anyone help please am very bad when it comes to js but kind of good at jquery. Jquery

<script async>
        $(document).on('click', '.pagination a', function(event){
            event.preventDefault();
            $(".page-loader").removeClass('page-loader-hidden');
            var page = $(this).attr('href').split('page=')[1];
            fetch_data(page);
        });
        function fetch_data(page){
            $.ajax({
                url: '/pagination/fetch_browsergames_data?page='+page,
                success: function(data){
                    $("#games_content").html(data);
                    $('html, body').animate({scrollTop : 0},1000);
                    var lazyLoadInstance = new LazyLoad({
                        elements_selector: ".lazy"
                        // ... more custom settings?
                    });
                    $(".page-loader").addClass('page-loader-hidden');
                }
            })
        }
        //search box
  $(document).ready(function(e){
  $("#searchBox").keyup(function() {
  $("#show_upSearch").removeClass('d-none');
  var text = $(this).val();
  var textlen = $(this).val(),length;
  $.ajax({
  method:"GET",
  url:"/search-box/browser-game",
  data:{text:text},
  success:function(data){
  if (textlen != 0) {
  $("#show_upSearch").html(data);
  }else{
  $("#show_upSearch").html("");
  }
  }
  })
  });
  });
</script>

Please sign in or create an account to participate in this conversation.