jquery - WordPress jQuery 点击事件

标签 jquery wordpress syntax

我这里有这段代码,应该发送警报...

jQuery(".wpcart_gallery .thickbox").click(function($){
            alert('hi');
        });

但它不起作用:(没有错误,警报也永远不会出现。我的 header 中有正确的 JQuery.js 文件...我的语法有问题吗?

这是 HTML 代码

<div class="wpcart_gallery" style="text-align:center; padding-top:5px;">
<a class="thickbox cboxElement" href="DSC_0037.jpg" rev="DSC_0037.jpg"></a>
<a class="thickbox cboxElement" href="DSC_0036.jpg"  rev="DSC_0036.jpg"></a>
<a class="thickbox cboxElement" href="DSC_0118.jpg" rev="DSC_0118.jpg"></a>
</div>

我试图在单击 wpcart_gallery 内的链接之一时发生单击事件。

这是页面,放大大图有三个图像,我正在寻找单击事件来触发,如果单击这些图像中的任何一个...http://www.taranmarlowjewelry.com/?wpsc-product=产品-1-2

最佳答案

我通过

解决了这个问题
jQuery(".wpcart_gallery img").click(function($){
            alert('hi');
        });

关于jquery - WordPress jQuery 点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12466653/

相关文章:

html - 如何在 Chrome 中隐藏 div

php - 如何从wordpress菜单中获取单个特定项目

python - 循环中一次打印单个字符

java - Java Thread trail 中 "new"周围的括号?

javascript - 使用远程内容的 jQuery UI 模态对话框表单

css - 如何使图像在不同屏幕上拉伸(stretch)

jquery - jquery 移动标题按钮上没有样式

php - 使用 pchart 和 mysql 创建图表 - 提供的示例中的正确语法

javascript - 同步功能运行时显示视觉指示器

javascript - iframe 中<span> 中的innerHTML 不会更改html