将多选择器jQuery对象的每个选择器作为字符串

时间:2011-09-09 16:47:10

标签: jquery string selector

如果我将多个选择器传递给jQuery,我如何将每个选择器的选择器区分为单独的字符串?例如:

$('#selector-a, #selector-b, #selector-c').each(function(){
    console.log( $(this).selector ); // logs an empty string
});

1 个答案:

答案 0 :(得分:1)

$.each($('#selector-a, #selector-b, #selector-c').selector.split(','),
       function(index, value) {
           console.log(value);
       }
);