考虑以下:
var a = 'jesus';
if(a == 'something' || a == 'nothing' || a=='anything' || a=='everything'){
alert('Who cares?');
}
Run Code Online (Sandbox Code Playgroud)
有没有办法缩短它?
Javascript中有什么东西if (a=='bbb'||'ccc')吗?
另外,jQuery可以在这里帮忙吗?
(function($) {
$.fn.top_islides = function(){
var ajax_init = function(){
init_islides();
setTimeout(function(){picmove()},300);
};
//.....
};
})(jQuery);
Run Code Online (Sandbox Code Playgroud)
在另一个文件中准备好的doucument中调用它
$('#top_slides').top_islides();
$('#top_slides').top_islides().ajax_init();
Run Code Online (Sandbox Code Playgroud)
我认为它应该工作,我得到一个错误,有什么问题?
今天我将使用CSS制作一些关键帧动画.我正在使用以下CSS:
-webkit-animation: ballanim 5.6s infinite;
-o-animation: ballanim 5.6s infinite;
animation: ballanim 5.6s infinite;
Run Code Online (Sandbox Code Playgroud)
但是有一个很大的问题,我不知道我的代码是否存在问题,或者它是否是Firefox问题.相比之下,这些动画的10倍:
我在这里上传了我的网页:
http://hkwh01.99k.org/test/services.html
Firefox不适合CSS动画吗?有人知道这个的原因吗?我应该想到另一种做动画的方法吗?
为什么这不起作用?
var sheep = function(options){
this.options = {sizes: 100,
eat: 100,
colors: 'white',
running: function () {
return this.sizes + this.eat;
}
}
};
var blacksheep = new sheep({colors:'black'});
alert('blackcsheep color is ' + blacksheep.colors);//error undefined
alert('blackcsheep color is ' + blacksheep.options.colors);// it return white
alert('blackcsheep running is ' + blacksheep.running());//error
Run Code Online (Sandbox Code Playgroud) XUL box for div element contained an inline br child, forcing all its children to be wrapped in a block.
Run Code Online (Sandbox Code Playgroud)
它只是一个警报,但不是致命的错误,网页不会有任何问题,但这个问题发生在我的firebug控制台,这很烦人,如何防止这种情况?或者如何在firebug中忽略这些错误?
我怀疑它是由此引起的:
#top_icon01{
position:relative;
background-image : url('../hill_header/img/top_Icon_i01.png');
background-repeat : no-repeat;
background-size : 56px 56px;
background-position: 50% 20px;
width : 172px;
height : 130px;
padding-top : 25px;
text-align: center;
display:block;
display:-webkit-box;
display:-moz-box;
-webkit-box-pack:center;
-webkit-box-align:center;
-moz-box-pack:center;
-moz-box-align:center;
}
Run Code Online (Sandbox Code Playgroud)
我提供了一些更多的细节:我没有勾选显示chrome错误,看到这是非常烦人的.
如果我删除顶部标题:
<div id='topHeader'>
<section id='top_middle_panel'>
<div id='top_ryan'>
<span class='float'>
<div id='top_icon01' class='top_icons'>
<h1>Design</h1><br><h6>Create Value</h6>
</div>
</span>
<span class='float'>
<div id='top_icon02' class='top_icons'> …Run Code Online (Sandbox Code Playgroud) 如何让div看不见仍然可以点击?显示隐藏或隐藏()将使它消失,但我希望用户仍然能够点击它,因为我把它放在另一个对象的顶部
var abc = {
'a': 10,
'b': 10,
c: function() {
//like if I have many many functions in c
init_a();
multiple();
function init_a() {
abc.a = 30;
}
function multiple() {
alert(abc.a * abc.b);
}
function minus() {
alert(abc.a - abc.b);
}
return {
function myalert() {
var result = abc.a + abc.b;
alert(result);
}
}
},
d: function() {
abc.c.myalert(); // ??? error??
abc.c().myalert(); // ??? error?? **it run all functions in c but not just myalert, strange …Run Code Online (Sandbox Code Playgroud)