【发布时间】:2011-10-20 05:03:00
【问题描述】:
我的页面上有四个 DIV 元素。每个都有自己的数组,我使用 data() 附加。
根据用户交互(在页面导航上)jquery 将加载的元素 ID 存储在其中一个数组中。
设置和推送元素的工作原理如下:
$('div:jqmData(role="panel")').each(function(index) {
if ( $(this).jqmData('hash') == 'history' ) {
var id = $(this).jqmData('id');
$(this).data("stack", []);
// inital entry = startpage
$(this).data("stack").push('#'+$(this).find('.starter').attr('id'));
}
});
添加元素:
$('div:jqmData(role="page")').bind( "pagechange", function( event) {
var $targetPanel = $( event.target ),
$targetPage = '#'+ $.mobile.path.stripHash( hash );
$targetPanel.data("stack").push($targetPage);
});
我现在需要知道哪个数组最长,最后一个条目是什么?
不知道怎么做...
无法使用 maxValue 或数学,因为我只有 #pageSome、#pageOther 等条目。一定有比遍历所有数组、获取它们的长度并尝试 if-else 最高值更好的方法...
感谢您的帮助!
【问题讨论】:
标签: jquery arrays jquery-mobile