jQuery - switch statement example

0 votes
253 views
added Aug 15, 2019 in jQuery by lcjr First Warrant Officer (9,190 points)
var page = getParameterByName('field_category_value');
switch(page){
  case "news":
    $('.news-tabs>li').removeClass('active');
    $('.news-tabs').find('li').filter(function () {
            return $(this).text() == 'Land Rover News';
        }).addClass('active');
    jQuery(".page-header").html("All Land Rover News");
    jQuery("ol.breadcrumb li:last-child" ).html(jQuery(".page-header").html());
  break;
  case "defender":
    $('.news-tabs>li').removeClass('active');
    $('.news-tabs').find('li').filter(function () {
            return $(this).text() == 'Defender';
        }).addClass('active');          
  break;
  case "series":
    $('.news-tabs>li').removeClass('active');
    $('.news-tabs').find('li').filter(function () {
            return $(this).text() == 'Series';
        }).addClass('active');
  break;
  case "discovery":
    $('.news-tabs>li').removeClass('active');
    $('.news-tabs').find('li').filter(function () {
            return $(this).text() == 'Discovery';
        }).addClass('active');
  break;
  default:
  jQuery(".page-header").html("All Land Rover News");
  jQuery("ol.breadcrumb li:last-child" ).html(jQuery(".page-header").html());
  break;
}

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...