Hey guys I’m creating a jquery plugin and I’m trying to either get the table row selector from table or the table from table row selector.
$("#table tr").myPlugin();
$("#table").myPlugin();
Basically within the plugin I need to access the table selector or row selector. So within the first version with the row I need this.
var table = $('#table');
Or within the regular table version I need this.
var row = $('#table tr');
How would I do this? Thanks.
From within the plugin this.selector will give you the selector string, or the selector method that was used, like .children(td). this.context will give you the original context of the selector.
you can play around with different selectors here: http://jsfiddle.net/MkCxD/