多个选项选中某一个的效果(用到siblings()方法)

点击哪一行就改变哪一行的样式 

 

$(function(){
  $(".yhq_list").click(function(){ 
  $(this).addClass('yhq_on').siblings().removeClass('yhq_on'); //当前元素加上样式,其他兄弟元素去掉样式
  })
})
siblings()表示选中其他所有兄弟元素
posted @ 2017-07-05 15:01  javenLee  阅读(314)  评论(0)    收藏  举报