我正在开发一个网站。如果 URL 与特定 URL 匹配,我需要能够执行特定功能。这是我正在尝试做的事情的示例:
如果 URL 与此 URL 匹配:
http://www.example.com/EIFS-items/search.php?l2=3,15,25
然后我想让 jQuery 添加一个“show”类到下面的“content”类的 div 中。
这可能吗?
<html>
<head>
<title>Title</title>
<style type="text/css">
.content {
display: none;
}
.show {
display: block;
}
</style>
</head>
<body>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div><!-- end .content -->
</body>
</html>
最佳答案
var url = "http://www.example.com/EIFS-items/search.php?l2=3,15,25";
$(function(){
if (location.href==url){
$('.content').show();
}
});
关于jquery - jQuery 可以检测特定的 URL 并根据该 URL 执行功能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4619601/