AI智能
改变未来

Jquery解决collapsed收缩问题

<script>$(document).ready(function(){$(\'course-button\').on(\'click\',funtion(){var oldae = $(this).attr(\'aria-expended\') === \'true\';// 设置或返回被选元素的值$(\'.course-button\').attr(\'aria-expanded\',\'false\'\');$(\'.panel-group\').find(\'.course-button\').each(function(){ // each() 规定为每个匹配元素运行的函数var _span = $(this).find(\'.glyphicon\'); // find() 通过选择器、jQuery 对象或元素来筛选获得当前元素集合中每个元素的后代if  ($(this).attr(\'aria-expandaed\') ===\'true\'){_span.removeClass(\'glyphicon-plus\');_span.addClass(\'glyphicon-minus\');}else{_span.removeClass(\'glyphicon-minus\');_span.addClass(\'glyphicon-plus\');}});$(this).attr(\'aria-expanded\',!oldae);var glyphicon = $(this).find(\'.glyphicon\');if($(this).attr(\'aria-expanded\') === \'true\'){glyphicon.removeClass(\'glyphicon-plus\');glyphicon.addClass(\'glyphicon-minus\');}else{glyphicon.removeClass(\'glyphicon-minus\');glyphicon.addClass(\'glyphicon-plus\');}}});});});</script>
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Jquery解决collapsed收缩问题