Below is a code used in many userscripts:
function with_jquery(f) {
var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + f.toString() + ")(jQuery)";
document.body.appendChild(script);
};
I understood everything in it except this line:
script.textContent = "(" + f.toString() + ")(jQuery)";
I knew that text content sets the text content of the script( of course), but I just can't understand everything after the =
. shouldn't this be:
script.textContent = string;