Koerr
Koerr

Reputation: 15733

how to get selector from jquery object?

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.

Upvotes: 3

Views: 431

Answers (3)

codeporn
codeporn

Reputation: 990

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

Upvotes: 1

DannyLane
DannyLane

Reputation: 2096

$('#ggggg').selector 

is the correct way of getting the selector for the jQuery object.

This is what you had in your original post, have you tried it?

Upvotes: 0

deceze
deceze

Reputation: 522626

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

Upvotes: 4

Related Questions