有什么区别
$(function(){
});
Run Code Online (Sandbox Code Playgroud)
和
$(document).ready(function() {
});
Run Code Online (Sandbox Code Playgroud) 可能重复:
感叹号在功能之前做了什么?
我今天第一次看到了这样的格式化的函数:
!function(){}();
Run Code Online (Sandbox Code Playgroud)
前面的感叹号是什么?我认为它的功能与:
(function(){})();
Run Code Online (Sandbox Code Playgroud)
但是......这里发生了什么?
我正在尝试向网站添加滑块.
当我在本地测试它在标准的html文件中工作正常,但当我尝试将其传输到wordpress网站时,我不断收到此错误:
未捕获的TypeError:无法读取未定义的属性"browser"
它指向问题代码中的第11行
isIE = $.browser.msie,
Run Code Online (Sandbox Code Playgroud)
我不确定它在基本文件中工作的是什么,而不是wordpress live site.
这是滑块的jquery文件 - 我确定它很简单,但我还没想到它.
谢谢瑞恩
var current = 0,
imagenum = {},
heroName = {},
speed = 500,
messageDelay = 10000,
expanded = false,
animating = false,
easeType = 'easeOutQuint',
scrollEase = 'easeInOutExpo',
easeTypeCB = 'cubic-bezier(0.770, 0.000, 0.175, 1.000)',
isIE = $.browser.msie,
currenth = 0,
anim = false,
isLoading = false,
autoHero = '',
heroSlideLoading = false,
heroSlideDuration = 1000,
gt1000 = false,
scrollSpeed = 1000,
scrollAnimation = false,
autoCarousel = …Run Code Online (Sandbox Code Playgroud) 我收到以下错误,似乎是Javascript无法解释$符号.
未捕获的TypeError:undefined不是函数main.js:1(匿名函数)main.js:1
下面附有的是main.js代码.这回事工作得很好.我试图找出指向哪里寻找问题的指针,即主题,jquery导入等.欢迎任何建议.
$(function(){
var cardHeight = 0;
function _setCardHeight(){
$(".subpage-box").each( function(){ var current_height =
$(this).height();
cardHeight = ( current_height > cardHeight) ? current_height :
cardHeight;
}); $(".subpage-box").each( function(){ if( $(this).height() <
cardHeight ){ $(this).height( cardHeight ); } });
}
function _setNavStyle(){
$("menu-main-menu > li > a").each( function(){
var text = $(this).html();
if( $(this).contains("for") ){
}
});
}
_setNavStyle();
_setCardHeight();
});
Run Code Online (Sandbox Code Playgroud) 我正在自定义 wordpress 主题,为什么在尝试在搜索框的输入字段中键入时出现此错误,我的 html 代码是
<div class="mysearchdiv">
<input type="" name="" class="mysearch">
<ul class="skills-list" id="skills_list"></ul>
</div>
Run Code Online (Sandbox Code Playgroud)
和backbone.js 代码是
jQuery(document).ready(function(){
var mymodel= Backbone.Model.extend({
defaults:function(){
return{
name:''
}
}
});
var mycollection=Backbone.Collection.extend({
model:mymodel
});
var mynewcollection= new mycollection();
var myview=Backbone.View.extend({
model:mynewcollection,
el:'.mysearchdiv',
events:{
'keypress .mysearch':'search'
},
initialize:function(){
console.log("init");
var view=this;
this.skill_list=this.$('ul.skill-list');
view.skills={};
this.$el.find('input.mysearch').typeahead({
minLength:0,
items:10,
source: function(query, process) {
console.log("Skill_Control typeahead source");
console.log(query);
console.log(process);
console.log(ae_globals.ajaxURL);
if (view.skills.length > 0) return view.skills;
//getting error at this point
//where ae_globals.ajaxURL is ajax url in wp …Run Code Online (Sandbox Code Playgroud) 我在这里遇到了一些 javascript 问题,因为我不断收到错误,但无论我做什么,我仍然收到错误 - 错误位于第 400 行(http://www.stuartgreen.me.uk/pontins- events/wp-content/themes/genesis-sample/js/css3-animations.js),据我了解,这与 $ 和 WordPress 有关(我不知道 JS),但我尝试过我在上面看到的东西这里,比如使用文档。和 jQuery,代替了 $,但它只是带来了不同的错误:/
任何 JS 专家都可以在这里指出我正确的方向吗?