LoginSignup
0
2

More than 5 years have passed since last update.

javascript URLからクエリを取得し、クラスとして扱ったり、イベント時に使用する

Last updated at Posted at 2017-11-16

URLからクエリを取得し、クラスとして扱ったり、イベント時に使用する

var query = window.location.search.replace("?page=" , "");

var advName = [
  {
    "name" : "1111111"
  },
  {
    "name" : "2222222"
  },
  {
    "name" : "333333333"
  },
  {
    "name" : "444444444"
  },
  {
    "name" : "5555555555"
  }
];

var advTitle = function(){
  situation = "page-" + query;
    val = $("#" + situation).index(".advBox li");//jQuery使用
    document.title = advName[val].name;
}
advTitle();

window.onload = function(){
  $(advBg).addClass(situation);//jQuery使用
  val = $(this).index(".advBox li");//jQuery使用
    var charaClick = function(){
       i = "";
       for(var i = 0; i < Selector.length; i++){
         Selector[i].addEventListener('click', function(e) {
           val = $(this).index(".advBox li");//jQuery使用
           getAttr = this.getAttribute('id');
           advBg.setAttribute("class", getAttr);
           replace = getAttr.replace("page-" , "");
         },false);
       }
     }
     charaClick();
};

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2