如何让 AppleScript 和 jQuery 触发“.click()” Safari 中的事件

发布于 2024-12-27 10:42:50 字数 521 浏览 2 评论 0原文

我正在尝试获取一些 javascript 代码,并将 jQuery 加载到 AppleScript 中,以触发“.click()”事件。

下面是有问题的代码:

var dayIdValue1 = 'z_event_date_picker_calendar_0_cell' + dayValue2;

var dayTd = document.getElementById(dayIdValue1).childNodes[0];
dayTd.click();

可能值得一提的是,我尝试让 jQuery 加载带有变量 dayIdValue1 的选择器,但我无法让它正常工作。

另外值得补充的是,我正在使用 Safari 来运行脚本,但它不断引发如下错误:

TypeError: 'undefined' is not a function (evaluating 'dayTd.click()')

您必须就此事提供的任何帮助都会有所帮助。

提前致谢。

I am trying to get some javascript code, with jQuery loaded in an AppleScript, to fire a '.click()' event.

Here's a look at the code in question:

var dayIdValue1 = 'z_event_date_picker_calendar_0_cell' + dayValue2;

var dayTd = document.getElementById(dayIdValue1).childNodes[0];
dayTd.click();

It's probably worth mentioning that I tried to get jQuery to load a selector with the variable dayIdValue1, but I couldn't get it to work without an error.

Also it's worth adding, that I am using Safari to run the script, but it keeps firing an error like this:

TypeError: 'undefined' is not a function (evaluating 'dayTd.click()')

Any help you would have to offer on the matter would be helpful.

Thanks in advance.

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

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

发布评论

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

评论(1

魂归处 2025-01-03 10:42:50

根据您的评论,它是一个链接,您可以使用 getElementsByTagName 来引用锚标记。

var dayIdValue1 = 'z_event_date_picker_calendar_0_cell' + dayValue2;
var dayTd = document.getElementById(dayIdValue1).getElementsByTagName("a")[0];
dayTd.click();

对于 jQuery,这只是

jQuery("#" + dayIdValue1 + " a").click();

假设 dayIdValue1 是一个有效的 id。

based on your comment that it is a link, you can use getElementsByTagName to reference the anchor tag.

var dayIdValue1 = 'z_event_date_picker_calendar_0_cell' + dayValue2;
var dayTd = document.getElementById(dayIdValue1).getElementsByTagName("a")[0];
dayTd.click();

With jQuery it would just be

jQuery("#" + dayIdValue1 + " a").click();

this assumes that dayIdValue1 is a valid id.

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