我想在此css更改中添加或减去'top'的值.而不是指定特定的像素数量,我想将20px添加到外部css提供的当前值.
目标是使列表向上移动.
$('.up').click(function(){
$('.list').css('top','-20px');
});
Run Code Online (Sandbox Code Playgroud)
HTML
<div id="container">
<ul class="list">
<li >first item</li>
<li class="active">second item</li>
<li>third item</li>
<li >fourth item</li>
<ul>
</div>
<a href="#" class="up">up</a>
<a href="#" class="up">down</a>?
Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法可以选择列表项,随着列表的继续添加一个css值.
很难解释所以让我展示和示例:
<ul class="list">
<li></li>
<li></li>
<li></li>
<li></li>
....
</ul>
Run Code Online (Sandbox Code Playgroud)
我想采用像这样的动态生成列表
<ul class="list">
<li style="left:0px;"></li>
<li style="left:10px;"></li>
<li style="left:20px;"></li>
<li style="left:30px;"></li>
....
</ul>
Run Code Online (Sandbox Code Playgroud)
我不确定这是否最好用jQuery完成,或者如果有一种类型的CSS选择器,我不知道这可以解决这个问题.
如果我使用jQuery,我认为它可能是这样的:
$('.list > li:nth-child(2)').css('left', '+=10px').next
Run Code Online (Sandbox Code Playgroud)
但我不知道如何擦除列表的其余部分并且每次都添加10px.我一直在玩'.next'和'.prev',但我不确定如何执行.
在此先感谢您的耐心等待,我是jQuery的新手.
我正在使用这段代码打开div并向下滚动它.它工作得很好,但只有我第一次使用它,即使在页面刷新它也不会再次工作.有谁知道为什么会这样?提前致谢!
这是URL(www.patrickorr.ca)
$(document).ready(function() {
$("div.ftropen")
.click(function(){
$("div#connect").animate({height: "500px" }, "fast");
$("div#ftrconnect").fadeOut("fast"); //hide connectbtn
$("div#ftrhide").fadeIn("fast"); //show hidebtn
$("#connect").scrollTop($("#connect").scrollTop() + 500);
return false;
});
$("div.ftrclose")
.click(function(){
$("div#connect").animate({height: "0px" }, "fast");
$("div#ftrhide").fadeOut("fast"); //hide hidebtn
$("div#ftrconnect").fadeIn("fast"); //show connectbtn
return false;
});
});
Run Code Online (Sandbox Code Playgroud) 抱歉,这似乎是一个菜鸟问题.今天早上我的大脑无法工作.
我试图执行多个if语句,但它们表现不正常.它似乎总是在找到它正在寻找的模板之后加载最少的模板.做这样的事情的最佳方法是什么:
$post = $wp_query->post;
if ( in_category('7') ) {include(TEMPLATEPATH . '/post-experts.php');}
if ( in_category('6') ) {include(TEMPLATEPATH . '/post-radio.php');}
if ( in_category('5') ) {include(TEMPLATEPATH . '/post-lifestyle.php');}
else {include(TEMPLATEPATH . '/singleorigional.php');
}
Run Code Online (Sandbox Code Playgroud)