jQUery fadeIn 基于 url?

发布于 2024-09-27 13:43:34 字数 165 浏览 0 评论 0原文

假设我传递了 url,example.php?mode=select&ID=1#age

是否可以根据 url 添加 jquery fadeIn?

该网址将位于另一个页面上,当用户单击它时,将加载一个页面,因此提交的年龄应该淡入。

如果这不可能,还有其他方法吗?

let say i pass url, example.php?mode=select&ID=1#age

is it possible to add jquery fadeIn based on url?

this url will be on another page, when user click it, a page will load and hence the age filed should be fade in.

if this not possible, is there any other way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淑女气质 2024-10-04 13:43:34

您可以检查是否存在 location.hash 设置 document.ready ,如果是这样,调用 .fadeIn()< /code>在该元素上,如下所示:

$(function() {
  if(location.hash) $(location.hash).fadeIn();
});

例如,如果您的 URL 是 ....#age,则该内容会在 id="age" 元素。

You can check for the if there's a location.hash set on document.ready and if so, call .fadeIn() on that element, like this:

$(function() {
  if(location.hash) $(location.hash).fadeIn();
});

So for example if your URL was ....#age, this would fade in the id="age" element.

秋叶绚丽 2024-10-04 13:43:34

我已经用这样的 URL 做了类似的事情:

http://site.com/page/view/ #219

var theHash = window.location.hash;
theHash=theHash.substr(1);

$("#f"+theHash).css('backgroundColor',"#E47527");
$("#f"+theHash).animate({backgroundColor: "#ffefe3" }, 2000);

然而,可能是更有效的方法。用于 ID 类似于“#f111”的链接

I've done something similiar with a URL like this:

http://site.com/page/view/#219

var theHash = window.location.hash;
theHash=theHash.substr(1);

$("#f"+theHash).css('backgroundColor',"#E47527");
$("#f"+theHash).animate({backgroundColor: "#ffefe3" }, 2000);

probably more efficient ways, however. used on links with an ID like "#f111"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文