-1

I am programming on google using the tampermonkey extension, unfortunaly , I can't use jsquery.

I tried to hide an element on the second click, something like a toggle function.

Here it is :

function HideRanks (zEvent) {
    document.getElementById("UserList").classList.toggle('ButtonClickAction');
}

function ButtonClickAction (zEvent) {
   var zNode       = document.createElement ('p');
    var href1 = "/profile/"+firstuser.nick+"-"+firstuser.id;
    var href2 = "/profile/"+seconduser.nick+"-"+seconduser.id;
    var href3 = "/profile/"+thirduser.nick+"-"+thirduser.id;

    zNode.innerHTML = '<p id="UserList"><a style="background-color:Gold;" href="'+href1+'">'+firstuser.nick+'</a>-'+firstuser.points+' points '+firstuser.rank+'</p><br><p><a style="background-color:Orange;" href="'+href2+'">'+seconduser.nick+'</a>-'+seconduser.points+' points '+seconduser.rank+'</p><br><p><a style="background-color:Gray;" href="'+href3+'">'+thirduser.nick+'</a>-'+thirduser.points+' points '+thirduser.rank+'</p>';
    document.getElementById ("myContainer").appendChild (zNode);

}

Why the HideRanks function doesn't work ?

Hakar
  • 1
  • 2

1 Answers1

0

zNode.innerHTML = '<p id="UserList" onclick="HideRanks()">.....</p>';

Try This i have Tested in Jsfiddle its working but may cause problem for you as you are tampermonkey which i am not familiar so please comment if it doesn't work.

Toxy
  • 696
  • 5
  • 9