Get the current jQuery selector string?

前端 未结 8 1997
北恋
北恋 2020-12-01 18:00

When calling a custom plugin, how can I get the current selector string?

$(\'my_selector p\').my_plugin();

Would like to output my_se

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 18:29

    With selector deprecated i use

    index = document.getElementById('category').value
    select = $("#category option[value=#{index}]")[0].innerHTML
    

    just two lines of code

    or if you're really cheap with lines

    select = $("#category option[value=#{document.getElementById('category').value}]")[0].innerHTML
    

提交回复
热议问题