This function should change the background color of the object pressed
function colorMe(){ $(this).css('background-color', 'red'); }
I call it that
$('.colorme').click(colorMe);
and it changes the background of this div
<div class="colorme">Color Me</div>
The problem is that I want to do something else before running colorMe. Therefore, I can not use only $('.colorme').click(colorMe); . What I'm trying to do is something like this
$('.colorme').click(function(){ alert('something happens first, then colorMe is called'); colorMe();
but this does not affect the div. I think he lost control of the case. I need to pass it on and how?
javascript jquery
zmol
source share