如何在js的document.getElementsByClassName(a);的a使用变量, $('.a').addClass('flex-active');a
<olid="td12"><liclass="xx1flex-active"onClick="fb(1)"><imgsrc="./SC61E-PTN-electronic...
<ol id="td12"> <li class="xx1 flex-active" onClick="fb(1)"><img src="./SC61E-PTN-electronics_files/thumb(4).php"></li> <li class="xx2 " onClick="fb(2)"><img src="./SC61E-PTN-electronics_files/thumb(5).php"></li> <li class="xx3" onClick="fb(3)"><img src="./SC61E-PTN-electronics_files/thumb(6).php"></li> <li class="xx4 " onClick="fb(4)"><img src="./SC61E-PTN-electronics_files/thumb(7).php"></li> </ol> </div> <style> .xs1,.xs2,.xs3,.xs4{display:none;}.flex-active-slide{ display:block;} </style> <script type="text/javascript"> function fb(m){ if(m==1){$(".xs1").css("display","block");}else{$(".xs1").css("display","none");} var a="xx";a=a+m;b="xs";b=b+m; var q = document.getElementsByClassName(a);alert(q); $('.a').addClass('flex-active'); $('.b').addClass('flex-active-slide'); }</script>
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询