How do I get a jQuery selector's expression as text?

后端 未结 9 1268
迷失自我
迷失自我 2020-11-30 10:36

I have a jQuery selector, which has a chained function.

Inside the function I want to get access to the TEXT representing the expression for the selector.

         


        
9条回答
  •  我在风中等你
    2020-11-30 11:18

    well, I'm still trying to figure out if you are trying to get the element name? or the id and/or class or all of it.

    You can get element with this

    var element =$(this).get(0);
    var id = $(this).attr('id');
    var class=$(this).attr('class');
    

    not sure what happens if you have more than one class. might go into an array or something, and you could get that with the indexes.

提交回复
热议问题