As in jQuery 1.9, the .selector property of jQuery objects has been removed. (I'm a little confused why exactly). I really use it in several unique scenarios, and I know that I could do other things to prevent this. Just wondering if anyone knows any other way to capture the selector with 1.9?
$('#whatever').selector // (would of returned '#whatever')
One example of where I need .selector is that I already have a group of checkboxes with the name name , and I want to see, inside this group, which one is checked:
jsFiddle DEMO
var $test = $('input[name="test"]'); console.log( $test ); console.log( $(':checked', $test).attr('id') ); // returns --undefined-- console.log( 'now with .selector: '); console.log( $($test.selector + ':checked').attr('id') ); // returns correct
From the docs: .selector for jQuery objects
The remaining target of the deprecated .selector property in the jQuery object must support the deprecated .live () event. In 1.9, jQuery no longer attempts to save this property in chain methods, since the use of chain methods was never supported with .live (). Do not use the .selector property for a jQuery object. The jQuery migration plugin is not trying to save this property.
Mark Pieszak - DevHelp.Online
source share