jQuery:如果url包含#work,则执行某项操作 [英] jquery: if url contains #work then do something
本文介绍了jQuery:如果url包含#work,则执行某项操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图编写一个脚本,该脚本允许我在输入特定网址时加载某些事件.
I tried to write a script which allow me to load certain events when I enter specific url.
我的代码如下:
$(function(){
var url = window.location.pathname;
$("url:contains('#Work')").animate({"left": "250"}, "slow");
});
但是它不起作用.有什么建议?感谢您的帮助.
But it doesnt work. Any suggestions? Any help is appreciated.
推荐答案
$(function() {
if ( document.location.href.indexOf('#Work') > -1 ) {
$('#elementID').animate({"left": "250"}, "slow");
}
});
这篇关于jQuery:如果url包含#work,则执行某项操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文