// jQuery on ‘j’ to avoid conflicts with page jQuery
var j;
// PUT YOUR CODE within main() below
function main() {
// setup jQuery on j to avoid any possible conflicts
j = jQuery.noConflict();
// outlines all existing <a> tags in red
// running .each() on a jQuery search executes the included function
// individually for each element it finds that matches the search
// (e.g. in this case, it runs the function redBorder() for each ‘a’
// tag). the parameter name ‘e’ refers to the found element
//
// j(‘a’).each(function() { redBorder(this); });
// this line sets up a continuous search for new elements on the
// page that might get inserted later. so, in this example, any
// HTML with an ‘a’ tag that gets inserted *after* the page loads
// will call redBorder() for each one in turn. this way you can
// catch and change anything that happens after the page load
// (e.g. a new news feed story on the Facebook newsfeed0
//ready(‘a’, function(e) { redBorder(e); });
ready(‘p’, myBackground);
//ready(‘p.byline’, myPfont);
ready(‘img’, hideImage);
ready(‘span’, hideCredit);
//ready(‘a’, hideTheKids);
ready(‘h2 a’, function(e) {
var text = j(e).text();
if(text.contains(“Xi”)) {
j(e).css(‘backgroud-color’,’black’);
}
});
//j(‘h2 a:contains(“Xi”)’).css(‘background-color’,’black’);
j(‘li.date’).css(‘background-color’,’black’);
//var xi = (‘h2:contains(Xi)’)
// this function could do anything with the results it receives
// ‘jnode’ refers to the jquery object the initial jQuery search
// found, so we refer to it and then continue on with familiar
// jQuery statements
function redBorder(e) {
j(e).css(‘border’,’1px solid red’);
}
function myBackground(e) {
j(e).css(‘background-color’,’black’);
}
function myPfont(e) {
j(e).css(‘text-color’,’black’);
}
function hideImage(e) {
j(e).css(‘opacity’,’0′);
}
function hideCredit(e) {
j(e).css(‘opacity’,’0′);
}
function hideTheKids(e) {
j(e).css(‘background-color’,’black’);
}
}
// run the main function
main();
// utility functions we’ll use during the semester
// are below. for now it’s just another version of
// contains we can use to test string content
// cleaner syntax than match()
String.prototype.contains = function(it) { return this.indexOf(it) != -1; };
// close the opening invoked function
})();