$("form img[onclick]").each(function(i){ if($(this).attr("onclick") == "confirm()") { $(this).css("border","2px solid red"); } }); //Find all of the images with an onclick event of confirm() and Makem red. function confirm() { alert("red") } function somethingelse() { alert("not red") } <img src="/jquery/images/apple.png" height="48" width="48" border="0"> <img src="/jquery/images/baseball.png" height="48" width="48" border="0" onclick="confirm()"> <img src="/jquery/images/banana.png" height="48" width="48" border="0" onclick="somethingelse()"> <img src="/jquery/images/basketball.png" height="48" width="48" border="0">