12345678910111213141516171819202122232425262728293031323334353637class="classification"class="cf_commodity only_title"商品分类class="cf_list"class="cf_allGoods"class="cf_listATitle"-查看所有商品class="cf_agClassFi"按销量按价格按商品按收藏class="cf_upgradedClass"class="cf_listATitle"-各种水果class="cf_upClassList">奇异果>车厘子/樱桃>芒果>牛油果>火龙果>苹果>橙子>凤梨>榴莲>山竹>木瓜>柠檬>百香果class="cf_upTextBooks"class="cf_listATitle"-各种蔬菜class="cf_upClassList">土豆>番薯>山药>莲藕>净菜
1234567891011121314151617181920212223242526272829303132333435363738394041.classification {width:227px;height:auto;border:1px solid #e0e0e0;box-sizing:border-box;margin:0 0 15px 0;}.cf_listATitle {font-size:14px;height:14px;line-height:14px;color:#666666;padding:10px 0;font-weight:700;cursor:default;border-bottom:1px dashed #e0e0e0;}.cf_listATitle>i {display:inline-block;vertical-align:baseline;margin:0 9px 0 0;width:10px;height:11px;font-weight:bold;color:#ffffff;background:#cccccc;line-height:9px;font-style:normal;text-align:center;}.cf_listATitle>span {display:inline-block;}.cf_agClassFi {padding:10px 0;}.cf_agClassFi>a {display:inline-block;font-size:14px;height:14px;line-height:14px;
123456789101112$(function() {$(".cf_listATitle").on("click", function() {$(this).next().toggle(1000, function() {console.log($(this).prev().find("i").text());if ($(this).prev().find("i").text() == "-") {$(this).prev().find("i").text("+");} else {$(this).prev().find("i").text("-");}});}); // 左侧导航 商品分类 点击隐藏 or 显示})
各位道友:
经过某位大神的指点后,改过的代码如下:
$(function() { $(".cf_listATitle").on("click", function() { $(this).next().stop().toggle(1000, function() { console.log($(this).prev().find("i").text()); if ($(this).prev().find("i").text() == "-") { $(this).prev().find("i").text("+"); } else { $(this).prev().find("i").text("-"); } }); }); // 左侧导航 商品分类 点击隐藏 or 显示 })回复