Quick and silly jQuery selector question.
Why this does not work: jsFiddle demo
//config
var ThisTable = $('.ReallyLongSillyTableName');
// Function
$(ThisTable + ' > tbody > tr > td:last-child').each(function() {
$(this).append('Sales Orders: ');
});
But, this does work: jsFiddle demo
$('.ReallyLongSillyTableName td:last-child').each(function() {
$(this).append('Some Text');
});
Any suggestions much appreciated.
You can use either this:
or this:
var ThisTable = $('.ReallyLongSillyTableName');
is jQuery object (javascript object)$(ThisTable + ' > tbody > tr > td:last-child')
here in()
you have javascript object + string, that will not give you full string (NOT string + string!)You need
var ThisTable = '.ReallyLongSillyTableName';
$('.ReallyLongSillyTableName');
is a jQuery object, so you can't use it as String.So try
and you can use
ThisTable
as above or$(ThisTable)
(to make it jquery object) for other purpose.Try like below,