gpt4 book ai didi

javascript - jQuery 目标通用类项目,但具有触发单击的唯一 href

转载 作者:行者123 更新时间:2023-11-28 15:41:31 26 4
gpt4 key购买 nike

我正在尝试根据哈希值是否附加到网址卸载来定位具有唯一 href 值的通用项目类,我想模拟通常在页面上发生的点击。

jQuery:

if(window.location.hash) {
var hash = window.location.hash;
function showHashVideo() {
jQuery("a.btn").attr("href", hash).trigger('click');
}
jQuery(showHashVideo);
}

HTML:

<a class="btn btn-mini" href="#help-video-modal-Graphing" data-url="video-url" data-title="Graphing">Watch Video</a>

最佳答案

据我所知,您想要查找与 A 元素匹配的元素 HREF。你可以这样做:

jQuery("a.btn[href='" + hash + "']").trigger("click");

这将触发对带有 href=hasha.btn 的点击。

关于javascript - jQuery 目标通用类项目,但具有触发单击的唯一 href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23612178/

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