I would strongly recommend using jQuery, but then you should better use if for inserting the new label as well, to get a already jQuery-wrapped object. Please see:
http://api.jquery.com/category/manipulation/dom-insertion-around/[
^],
http://api.jquery.com/category/manipulation/dom-insertion-inside/[
^],
http://api.jquery.com/category/manipulation/dom-insertion-outside/[
^].
Then the click event is written like this:
myLabel.click(function() {
var sender = $(this);
});
Please see:
http://api.jquery.com/click[
^].
If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[
^],
http://jquery.com[
^],
http://learn.jquery.com[
^],
http://learn.jquery.com/using-jquery-core[
^],
http://learn.jquery.com/about-jquery/how-jquery-works[
^] (start from here).
If you don't want to listen to a good advice and want to write it in Javascript by yourself from scratch, you can always add a handler by using
document.getElementById("myLabel").addEventListener("click", function(){ alert("Hello World!"); });
The sample above is a combination of samples shown here:
http://www.w3schools.com/js/js_htmldom_eventlistener.asp[
^].
—SA