I've managed to get a table from another page into a variable called res.
I need to pass this variable through a filter for search.
I'm getting the table row that corresponds by using .parents().
This filter works when the table is on the same page as the jQuery, but not when using $.get().
Below is my approach:
$.get('oncalltable.html', function(res) {
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var year = d.getFullYear();
var oncalldate = ((''+month).length<2 ? '0' : '') + month + '/' +
((''+day).length<2 ? '0' : '') + day + '/' + year % 100;
var search = oncalldate;
var todayoncall = $("span").filter(function() {
return $(this).text() == search;
}).parents('tr');
console.log(oncalldate, res, todayoncall);
$('.test span').append(todayoncall);
});
thisis different in the context of the.filter()function compared to the outer function. Are expecting thethisfrom$.get?documentwhich have text which is equal tosearchvariable? Can you include text value ofsearchandhtmlofspanelements at Question? What is purpose of filtering all span elements, then appending existingspanelement to.test span? element?