gpt4 book ai didi

javascript - jQuery 无法在 Wordpress 中工作 - 默认情况下工作

转载 作者:行者123 更新时间:2023-11-28 19:51:15 24 4
gpt4 key购买 nike

这里的这个小片段在 JSFiddle 中工作得很好,但是当我将它与 WordPress 按钮的 PHP 文件中的选项卡一起放入时,它什么也没做。我目前有标准的 JavaScript 来打开一个带有“确定”和“取消”的弹出对话框,但我想使用"is"、“否”和“取消”。

这里有什么问题吗?

http://jsfiddle.net/vvjj8/617/

HTML

<li class="level3 item578"><a id="btnOpenDialog" value="Confirm Dialog Box" href="#"><span>ArmA 2</span></a>

</li>
<div id="dialog-confirm"></div>

jQuery

function fnOpenNormalDialog() {
$("#dialog-confirm").html("Do you have Play WithSix installed?");
// Define the Dialog and its properties.
$("#dialog-confirm").dialog({
resizable: false,
modal: true,
title: "ArmA 2",
height: 250,
width: 360,
buttons: {
"Yes": function () {
$(this).dialog('close');
window.location.href = "http://www.fogamers.com/arma2.php";
},
"No": function () {
$(this).dialog('close');
window.open('http://play.withsix.com/', '_blank');
},
"Cancel": function () {
$(this).dialog('close');
}
}
});

}
$('#btnOpenDialog').click(fnOpenNormalDialog);

错误

Uncaught TypeError: undefined is not a function (index):76
(anonymous function) (index):76
f.event.dispatch jquery.min.js:3
h.handle.i

Uncaught TypeError: undefined is not a function widgetkit-dd62f244.js:13
(anonymous function) widgetkit-dd62f244.js:13
o jquery.js?ver=1.7.2:2
p.fireWith jquery.js?ver=1.7.2:2
w jquery.js?ver=1.7.2:4
d

Uncaught TypeError: undefined is not a function (index):203
(anonymous function) (index):203
o jquery.min.js:2
p.fireWith jquery.min.js:2
e.extend.ready jquery.min.js:2
c.addEventListener.B

最佳答案

cpilko 所说的是有效的,但如果您更喜欢在代码中使用 $ 变量(由于多种原因,它可能更容易),那么当您像这样调用 jquery 时重新定义它:

<script>
jQuery(document).ready(function($) {

// you can now use the $ variable
$("#dialog-confirm").html("Do you have Play WithSix installed?");

)};

</script>

关于javascript - jQuery 无法在 Wordpress 中工作 - 默认情况下工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23413370/

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