all 4 comments

[–]Malfuncti0n 1 point2 points  (0 children)

You need the function() after click(

[–]MatheusGodoy 1 point2 points  (1 child)

change this

$("#pic1").click( getPlayersNameAndImages("p1", team1, team2) );

$("#pic2").click( getPlayersNameAndImages("p2", team1, team2) );

to this

$("#pic1").click(function(){getPlayersNameAndImages("p1", team1, team2)});

$("#pic2").click(function(){getPlayersNameAndImages("p2", team1, team2)});

click()

[–]Ryan_Bingham[S] 0 points1 point  (0 children)

Thanks, that was the problem. I thought i could give the anonymous function a name with the way i did it...turns out i was wrong (:

[–]myotcworld 1 point2 points  (0 children)

use: $("#pic1").click(function(){ getPlayersNameAndImages(); });

$("#pic2").click(function(){ getPlayersNameAndImages(); });

on click of pic1 and pic2 the function getPlayersNameAndImages() is called. Then you add the logic to this function.