gpt4 book ai didi

javascript - 需要 jquery 通过点击不同的 div 来激活点击

转载 作者:行者123 更新时间:2023-12-03 12:09:10 35 4
gpt4 key购买 nike

我希望有人能提供帮助...我是 Jquery 的新手...我想要实现的只是点击超链接图像,但是当页面另一部分上的完全独立的 div 出现时,就会发生这种情况单击而不是我刚才提到的超链接图像。 ....超链接图像也需要不可见。如果有人想知道为什么我需要这个......这是因为我想要自己的自定义按钮,而不是我正在使用的 CMS 附带的标准按钮,并且它无法更改......它基本上是一个解决系统所有者建议的问题。

这是我认为可行的

<style>

#my-custom-button{
margin: 0 auto;
width: 200px
}


#the-standard-button{
display : none
}

</style>


<div id="my-custom-button">
<a href="#"><img src="../images/order-now.png"></a>
</div>

<div id="the-standard-button">
<?php
proprietary PHP here that renders the standard button
?>
</div>


<script type="text/javascript">
<!--
$(function(){
$("#my-custom-button").click(function(){
$("#the-standard-button").click();
});
});
-->
</script>

最佳答案

整体

<?php propiertary blah blah ?>

很难破译,但我的猜测是,处理程序是为 php 创建的任何内容生成的,即 php 生成的

<button id="phpButton">
blah
</button>

然后是一个类似的处理程序

$("#phpButton").click(....)

请注意,处理程序不在“#the-standard-button”上。因此,您需要确保在 $("#my-custom-button").click(...) 中调用 click() 时使用正确的选择器

看看这个 jsFiddle 。注意哪个辅助点击事件被触发。

关于javascript - 需要 jquery 通过点击不同的 div 来激活点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25043033/

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