JQuery将div ID转换为索引 [英] JQuery convert div ID to index

查看:70
本文介绍了JQuery将div ID转换为索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



请帮帮忙?



我有一把JQuery手风琴,想要以编程方式打开基于选项卡ID的特定选项卡。我觉得我需要在手风琴中获得带有所需ID的div的索引(?),然后调用



 $( #accordion)。accordion({active:numberOfDivToOpen}); 





问题是,如何在手风琴中获得正确的div数,我从API中了解到我可以打开手风琴标签关于它的0指数编号?



例如:



 < span class =code-keyword><   div     id   =  accordion >  
< h3 > 比勒陀利亚信息< / h3 >
< div id = 比勒陀利亚 > 一些文字< / div >
< h3 > 约翰内斯堡信息< / h3 >
< span class =code-keyword>< div id = johannesburg > 某些文字< / div >
< / div >







 $( #accordion)。accordion({active:  #pretoria}); 







提前谢谢!

解决方案

#accordion)。accordion({active:numberOfDivToOpen});





问题是,如何在手风琴中获得正确的div数,我从API中了解到我可以根据其0指数编号打开手风琴标签?



例如:



 <   div     id   =  accordion >  
< h3 > 比勒陀利亚信息< / h3 >
< ; div id < span class =code-keyword> = 比勒陀利亚 > 一些文字< span class =code-keyword>< / div >
< h3 > 约翰内斯堡信息< / h3 >
< span class =code-keyword>< div id = johannesburg > 一些文字< / div >
< / div >







 


#accordion)。accordion({active:< span class =code- string> #pretoria});







提前谢谢!


你孩子的一套将是

 parent = 

Hi all,

Please help?

I have a JQuery accordion, and would like to programmatically open a specific tab based on the ID of the tab. I feel that I need to get the index(?) of the div with the required ID in the accordion, and then call

$("#accordion").accordion({active: numberOfDivToOpen});



The problem however is, how do I get the correct number of the div in the accordion, as I understand from the API that I can open accordion tabs based on its 0-index numbering?

example:

<div id="accordion">
<h3>Pretoria info</h3>
<div id="pretoria">some text</div>
<h3>Johannesburg Info</h3>
<div id="johannesburg">some text</div>
</div>




$("#accordion").accordion({active: "#pretoria"});




Thank you in advance!

解决方案

("#accordion").accordion({active: numberOfDivToOpen});



The problem however is, how do I get the correct number of the div in the accordion, as I understand from the API that I can open accordion tabs based on its 0-index numbering?

example:

<div id="accordion">
<h3>Pretoria info</h3>
<div id="pretoria">some text</div>
<h3>Johannesburg Info</h3>
<div id="johannesburg">some text</div>
</div>





("#accordion").accordion({active: "#pretoria"});




Thank you in advance!


The set of your children will be

parent =


这篇关于JQuery将div ID转换为索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆