For Example, this will give me:
console.log($(".smartgridview-normal").selector)
//result is '.smartgridview-normal'.

My code is :
$( '.smartgridview-normal th' ).live( 'dblclick', function () {
var optimalWidth = parseFloat( $( this ).attr( 'data-width' ) );
console.log( $(this).selector );// At this point I need the selector
$(this).addClass('selected');
} );
My Log is giving me an empty string. There is no selector for ‘this’ object. Is there any way to get the selector of the element which ‘this’ is pointing to?
Thanks for your time.
Oh, I see where your problem is.
$(this)is not constructed using a selector, but rather by directly wrapping a DOM element, so it does not carry it anywhere. You can get the original selector obviously by doing$('.smartgridview-normal th').selector; but there’s a big difference between$('.smartgridview-normal th')and$(this).