I am trying to add a click event to a series of anchor tags, however,
it is now working for me.  Could someone please tell me what is wrong
with this code.

[code]
//previously created an array of strings called list_of_strings

var newTable = document.createElement('table');

for each(string in list_of_strings) {
  var newRow = document.createElement('tr');
  var newCol = document.createElement('td');

  var anchorEl = document.createElement('a');
  anchorEl.addEventListener('click', function(event) { alert
("test"); }, true);
  anchorEl.setAttribute('href', '#');
  anchorEl.innerHTML = 'Click Me';

  newCol.appendChild(anchorEl);
  newRow.appendChild(newCol);
  newTable.appendChild(newRow);
}
[/code]


What I would eventually like to do is make it so that the user can
save the string using GM_setValue.  So the function's click event
would need to call GM_setValue and pass in the string to be saved.  So
I imagine the event listener to be this in the end.

  [code]
  anchorEl.addEventListener('click', function(event, string)
{ GM_setValue(uniqueID, string); }, true);
  [/code]

However, right now I can't get the simple alert to work.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to