jQuery的each()方法

each()

为每个匹配元素,规定运行的函数
返回 false,用于停止循环
语法格式

$(selector).each(function(index,element))

参数说明

function(index,element)
要执行的函数

Index
可选参数,选择器的index位置

element
可选参数,当前的元素,也可使用”this”选择器

$(".ui-tabs-anchor").each(function () {
    var text = $(this).text();
    if (text == title) {
        var hrefval = $(this).attr("href");
        hrefval = hrefval.substring(6, hrefval.length);
        index = hrefval;
    }
})

tabs.each(function (index) {
    if (index > currentTabIndex) {
        var tabId = this.id;
        closeTab(tabId);
    }
});

猜你喜欢

转载自blog.csdn.net/nangeali/article/details/81177755