Can jQuery detect a specific URL and perform a function based off that URL?

后端 未结 3 857
Happy的楠姐
Happy的楠姐 2021-01-15 03:24

I have a site I\'m working on. I need to be able to perform a specific function if the URL matches a specific URL. Here\'s an example of what I\'m trying to do:

If

3条回答
  •  忘掉有多难
    2021-01-15 03:50

    Probably will be better to use the querystring location.search than location.href. This would cover subdomains/protocol changes.

    if(location.search == "?l2=3,15,25")
        $('.content').addClass('show');
    

提交回复
热议问题