views:

127

answers:

2

In most web browsers, you can execute JavaScript in the address bar (i.e.

javascript:alert('Test');

Is it possible to execute jQuery in the address bar?

+1  A: 

One word: yes :)

Use Firebug or the IE developer tools like you normally would, make sure that the current page has script references to the jQuery library, then go to town on your selectors!

It's a good way to test selectors and functionality before incorporating it into your code

EDIT: slightly mis-read the question, but the answer is still the same. Whether it's the address bar or the console window, you can use jQuery. Try putting javascript:$("#content").remove() into your address bar while viewing this page and see what happens ;)

Josh E
Of course if you have firebug you could just enter your commands directly into the console ...
Erik
yeah that would be a more optimal way of doing it
Josh E
@Erik: Depends on what the OP wants to achieve.
Felix Kling
I usually have fun putting JavaScript into the address bar. This isn't for debugging, but more for fun.
contactmatt
When I do this: javascript:x=$('.menu').css('border','1px solid #ff0000'), I get: [object Object] on the screen. Why?
Diodeus
because you're essentially telling the browser to display the value of `x`, which since it's a complex object, says `[object Object]`.remove the `x=` and you won't see that
Josh E
+1  A: 

Yep. here's an example where jquery is already on the page: http://meta.stackoverflow.com/questions/20420/countdown-app-for-devdays/20430#20430

Another way you could do it is by specifying a js file that first loads the JQuery library. maybe like this: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

Dan Lord