全部, 我下载了一个预先捆绑的JS/CSS表单应用程序,我试图在Wordpress中使用它。我有以下代码:
$(document).ready(function() {
/*----------------------------------------------------------------------*/
/* Parse the data from an data-attribute of DOM Elements
/*----------------------------------------------------------------------*/
$.parseData = function (data, returnArray) {
if (/^\[(.*)\]$/.test(data)) { //array
data = data.substr(1, data.length - 2).split(',');
}
if (returnArray && !$.isArray(data) && data != null) {
data = Array(data);
}
return data;
};
/*----------------------------------------------------------------------*/
/* Image Preloader
/* http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
/*----------------------------------------------------------------------*/
// Arguments are image paths relative to the current page.
$.preload = function() {
var cache = [],
args_len = arguments.length;
for (var i = args_len; i--;) {
var cacheImage = document.createElement('img');
cacheImage.src = arguments[i];
cache.push(cacheImage);
}
};
/*----------------------------------------------------------------------*/
/* fadeInSlide by revaxarts.com
/* Fades out a box and slide it up before it will get removed
/*----------------------------------------------------------------------*/
$.fn.fadeInSlide = function (speed, callback) {
if ($.isFunction(speed)) callback = speed;
if (!speed) speed = 200;
if (!callback) callback = function() {};
this.each(function() {
var $this = $(this);
$this.fadeTo(speed/2, 1).slideDown(speed/2, function() {
callback();
});
});
return this;
};
/*----------------------------------------------------------------------*/
/* fadeOutSlide by revaxarts.com
/* Fades out a box and slide it up before it will get removed
/*----------------------------------------------------------------------*/
$.fn.fadeOutSlide = function (speed, callback) {
if ($.isFunction(speed)) callback = speed;
if (!speed) speed = 200;
if (!callback) callback = function() {};
this.each(function() {
var $this = $(this);
$this.fadeTo(speed/2, 0).slideUp(speed/2, function() {
$this.remove();
callback();
});
});
return this;
};
/*----------------------------------------------------------------------*/
/* textFadeOut by revaxarts.com
/* Fades out a box and slide it up before it will get removed
/*----------------------------------------------------------------------*/
$.fn.textFadeOut = function (text, delay, callback) {
if (!text) return false;
if ($.isFunction(delay)) callback = delay;
if (!delay) delay = 2000;
if (!callback) callback = function() {};
this.each(function() {
var $this = $(this);
$this.stop().text(text).show().delay(delay).fadeOut(1000,function(){
$this.text('').show();
callback();
})
});
return this;
};
/*----------------------------------------------------------------------*/
/* leadingZero by revaxarts.com
/* adds a leding zero if necessary
/*----------------------------------------------------------------------*/
$.leadingZero = function (value) {
value = parseInt(value, 10);
if(!isNaN(value)) {
(value < 10) ? value = '0' + value : value;
}
return value;
};
});
我假设WordPress的任何冲突中造成的问题,所以我更新了最后的支架看起来像下面这样:
}, "jQuery");
然而,我仍然会有同样的错误。有谁知道什么会造成这个问题,以及如何解决这个问题?
在此先感谢!
我应该添加你需要在最后松开“jQuery” – RedEyedMonster
你是这样一个生活的节省!经过3天的调试,我发现这是我的问题的确切解决方案。尽管WordPress正在加载jQuery文件,但我无法访问文档中提到的提示。所以这个代码的确切代码就是'jQuery(document).ready(function($){''固定好了,谢谢大家分享。 – Devner
这也是Drupal中的同样的问题,谢谢 – nextgtech