Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get selector from jquery object?

Tags:

jquery

codes:

   var jqueryObj=$("#readme");
   alert(jqueryObj.length); // result == 0

can i get "#readme" from jqueryObj ? like:

   alert(jqueryObj.selector); //i want get "#readme"

BTW: i want to get selector,not element ID, and jqueryObj.length == 0.

like image 405
Koerr Avatar asked Mar 23 '26 11:03

Koerr


2 Answers

Uhm... have you tried? http://api.jquery.com/selector/

like image 138
deceze Avatar answered Mar 25 '26 00:03

deceze


Edit: Deleted 'half a page of incorrect code' due to endless discussion. Refer to decezes answer for complete solution ...

like image 24
codeporn Avatar answered Mar 25 '26 01:03

codeporn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!