課程
/前端開發
/Bootstrap
/玩轉Bootstrap(基礎)
求幫忙,不知道哪里錯了
2015-06-16
源自:玩轉Bootstrap(基礎) 5-16
正在回答
通過這種方法得到的都是原生對象list[i\j],所以.attr/.on什么的都沒有
arlenhui 提問者
zhanghongjie 回復 arlenhui 提問者
arlenhui 提問者 回復 zhanghongjie
<script> ????$(function(){ ????????$(".nav?li").click(function(){ ????????????$('.nav?li').removeClass("active"); ????????????$(this).addClass("active"); ????????}); ????}) </script>
慕少824372
<script>
? ? ? var $list = $("#list_1>li");
? ? ? function changeList(index){
? ? ? ? $list.each(function(num){
? ? ? ? ? $($list[num]).attr("class",null);
? ? ? ? })
? ? ? ? $($list[index]).addClass("active");
? ? ? }
? ? ? $list.each(function(index){
? ? ? ? $(this).on('click',function(){
? ? ? ? ? changeList(index);
? ? ? })
?</script>
<script> ??? ?????window.onload=function(){ ??????var?ul=document.getElementById("list_1") ??????var?li=ul.getElementsByTagName("li") ??????for(i=0;i<li.length;i++){ ??????? ??????????li[i].onclick=function(){ ??????????????for(j=0;j<li.length;j++){ ??????????????????li[j].className="" ??????????????} ??????????this.className="active" ??????????} ??????} ?????} ?????? ??</script>
你遍歷出來的原生DOM對象沒有.on方法
舉報
告訴你使用Bootstrap,并且能夠獨立定制出適合自己的Bootstrap
2 回答在DW實現不了
1 回答active加在progress-bar也可以實現動態
2 回答路徑不對嗎,實現不了
2 回答如何實現類似于這種評論,問答,筆記這種切換效果?切換不同標題顯示不同界面
5 回答為什么下拉菜單實現不了
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-06-16
通過這種方法得到的都是原生對象list[i\j],所以.attr/.on什么的都沒有
2017-07-29
2016-09-06
<script>
? ? ? var $list = $("#list_1>li");
? ? ? function changeList(index){
? ? ? ? $list.each(function(num){
? ? ? ? ? $($list[num]).attr("class",null);
? ? ? ? })
? ? ? ? $($list[index]).addClass("active");
? ? ? }
? ? ? $list.each(function(index){
? ? ? ? $(this).on('click',function(){
? ? ? ? ? changeList(index);
? ? ? ? })
? ? ? })
?</script>
2016-01-03
2015-06-16
你遍歷出來的原生DOM對象沒有.on方法