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

后端 未结 9 1259
迷失自我
迷失自我 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:41

    This will work if you want to access selector string in your function:

    $(this).html();
    

    This will also work if multiple selector are use,

    for instance,

    $('#id1,#id2').click(function(){
       alert($(this).html());
    });
    

提交回复
热议问题