如何使用jQuery在切换的无序列表中旋转项目符号图像
How to rotate a bullet image in toggled unordered list with jQuery
好的,我已经完全重新调整了我的方法(感谢superUntitled),并且正在取得进展。。。我有一个无序的列表,用户可以切换,我唯一剩下的问题是,当我展开一些项目,然后单击"显示所有城市"时,并非所有箭头都指向同一方向。所有箭头都会更改,包括已展开的列表项上的箭头。关于如何解决这个问题,有什么建议吗?
这是我的新Javascript:
$("#Names .airports").hide();
$("#Names .close").hide();
$('#Expand').click(function(){
$('h2').children(".close").toggle();
$('h2').children(".arrow-down").toggle();
if($(this).text() == 'Hide All Cities')
{
$(this).text('Show All Cities');
$('#Names .airports').slideUp('fast');
}
else
{
$(this).text('Hide All Cities');
$('#Names .airports').slideDown('fast');
}
});
$("#Names h2").addClass("state").click(function() {
$(this).parent().children(".airports").slideToggle('fast')
$(this).children(".close").toggle();
$(this).children(".arrow-down").toggle();
以下是说明剩余问题的小提琴:http://jsfiddle.net/d3pxx8ds/127/
提前感谢
这是我的旧JavaScript(现在只参考):
$(function() {
$('li.state').prepend('<img src="http://png-4.findicons.com/files/icons/2227/picol/32/arrow_sans_up_32.png" class="arrow"/>');});
$('.stateNames ul').hide();
$('.stateNames li').click(function(e) {
e.stopPropagation();
$(this).find('ul').toggle();
var value = 0
$(".arrow").rotate({
bind:
{
click: function(){
value +=180;
$(this).rotate(value)
}
}
});
});
我所做的只是替换订单,我将.rate移动到.thoggle函数之前,这将首先读取rotate,然后执行toggle函数,从而将变量设置为180,而不是等待toggle启动,不允许将变量设置成
$(function() {
$('li.state').prepend('<img src="http://png-4.findicons.com/files/icons/2227/picol/32/arrow_sans_up_32.png" class="arrow"/>');
});
$('.stateNames ul').hide();
var value = 0
$(".arrow").rotate({
bind : {
click : function() {
value += 180;
$(this).rotate(value)
}
}
});
$('.stateNames li').click(function(e) {
e.stopPropagation();
$(this).find('ul').toggle();
});
$(function() {
$('li.state').prepend('<img src="http://png-4.findicons.com/files/icons/2227/picol/32/arrow_sans_up_32.png" class="arrow"/>');
});
$('.stateNames ul').hide();
var value = 0
$(".arrow").rotate({
bind:
{
click: function(){
value +=180;
$(this).rotate(value)
if (value==180){
value=360;
}
else{
value=180;
}
}
}
});
$('.stateNames li').click(function(e) {
e.stopPropagation();
$(this).find('ul').toggle();
});
我添加了if语句,它适用于一个完整的循环,但在下一次切换时,箭头不旋转。希望这对现在有帮助,我会继续关注它
相关文章:
- 要求输入在数据列表中
- 从javascript创建一个列表
- 如何使用jQuery选择下拉列表的值
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- Javascript按钮下拉列表
- 如何使用json将对象列表从java转换为javascript
- 当ons惰性重复检测到更改时,如何使用ons旋转木马刷新列表
- 伪元素和旋转列表
- Jquery幻灯片中的列表,连接第一个和最后一个列表元素以创建旋转木马
- Javascript 循环
- 一键旋转列表
- 带有图像和边框的两列列表-旋转边框但不旋转图像
- 使用旋转木马效果循环列表
- 如何使用jQuery在切换的无序列表中旋转项目符号图像
- 如何制作HTML5旋转列表/转轮选择器/选择器
- 垂直引导旋转木马箭头和导航列表
- Onsen-ui:将旋转木马项目设置为0(带旋转木马列表的滑动菜单菜单)
- 按列表项引导旋转木马控制
- 链接在列表组不打开时触发(引导旋转木马调整)
- 如何使用JavaScript从外部文件加载广告列表来旋转页面上的广告