gpt4 book ai didi

jquery - 使用 url 参数触发 jQuery 点击事件?

转载 作者:行者123 更新时间:2023-12-01 06:19:49 26 4
gpt4 key购买 nike

我的页面上有一个 jQuery 单击函数,它会触发反馈表单 div 的打开。基本上我想指定一个无需单击即可触发此事件的网址。如 foo.com?formopen

这可能吗?我想我需要通过 url 传递一些数据,但不知道如何去做。

最佳答案

在 URL 中使用哈希,例如:

foo.com#formopen

然后找到加载时的哈希值,例如:

$(function(){

if (window.location.hash){
var hash = window.location.hash.substring(1);
if (hash == "formopen"){
openFeedbackForm();
}
}

});
<小时/>

演示:

代码:http://jsfiddle.net/J5cxc/

没有哈希的演示:http://fiddle.jshell.net/J5cxc/show (无警报)

带哈希的演示:http://fiddle.jshell.net/J5cxc/show/#foobar (已调用警报)

关于jquery - 使用 url 参数触发 jQuery 点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13492850/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com