I coded some jQuery that works, when injected into the Firefox web console, but doesn't when inserted into my code. Does anyone know why?

Thanks in advance

Here is the line:
Code:
$("button").attr("disabled", "disabled");
Here is the code segment:
Code:
  if (value == 0) {
    button_id.setAttribute("style","background-image: none; background-color: #FF0000;"); // red
    // show the correct answer button_id.setAttribute("style","background-image: none; background-color: #FFCC00; color: black;"); // yellow
    $("button").attr("disabled", "disabled");
    incorrect++;
    percent_correct();
    $("#ajaxArea").load("ajax-part.php");
  } else { // value == 1 and answer is correct
    button_id.setAttribute("style","background-image: none; background-color: #006600;"); // green
    $("button").attr("disabled", "disabled");	
    correct++;
    percent_correct();
    $("#ajaxArea").load("ajax-part.php");
  }