I'm trying to create a jquery script that will be run from the console of google chrome and will analyze a page. My problem is that when I run the following code:
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
alert($('a'));
I get a message box with null (bad result) But if I separate it to to executions like this:
step1:
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
step2:
alert($('a'));
It works great and I get [object] that is my desired result.
The question is what can I do to run this in a single batch?