Firebug and Javascript

November 24, 2009

Firebug allows you to run live javascript against the page. In my case, the website I was playing with already had jQuery included, so I could make use of the jQuery library.

In Firebug, enable the Console by clicking the down arrow to the right of the Console option.
If you want to write more than one line of javascript, then check the "Larger Command Line" option too.

This code, applied to one of the band pages at (for example on will append the number of wins as a number at the bottom of the HTML.

This code also shows an example of logging to the console within firebug.

var lCount = 0;
var lFirstPlace = $('.band-contest-position').each(function(){
  console.log('Looking at ' + $(this).prev().text());
  if ($(this).html() === '1')
    console.log('Counting this one!');
$('<div id="firstcount"/>').html("First places = " + lCount).appendTo("#content");