w/JavaScript
window.onload = function(){
//create new button
var btn = document.createElement("a");
btn.setAttribute("id", "addedbutton");
var btntxt = document.createTextNode("Run Me");
btn.appendChild(btntxt);
//inject new button
document.getElementById("sidebar").appendChild(btn);
//add event to new button
document.getElementById('addedbutton').onclick = function(){
alert("Success");
}
}
w/JQuery
$(document).ready(function(){
var test = $("<a href='#'>Run Me</a>").click(function(){
alert("Success");
return false;
});
$("body").append(test);
});