tags:

views:

56

answers:

3
<div id='one'>one</div>
<div id='two'>two</div>

function Red(e)
{
  $(e.target).css('color','red');  
}

// if i bind an event click to div='one' with fn "Red", function "Red" will receive e="div one", now i want to bind some event on div=two so that it send div=one to function Red.

remember: i don't want to bind any event to div=one

+2  A: 
$('#two').bind('click', function () {
  e.target = $('#one');
  return Red(e);
});

but this is not really great, maybe you could modify your Red function to that:

function Red(el)
{
  $(el).css('color','red');  
}
$('#two').bind('click', function () {
  return Red($('#one'));
});
mathroc
i dont want to just change color your above code somewhat closer to my requirement
Praveen Prasad
+1  A: 
$('#two').click(function(){
    Red({target: $('#one')[0]});
});
PetersenDidIt
A: 

If all your divs have the id attribute set, why not just do $('#one') to retrieve the div in your function?

Michael Mior
It is very very wrong for multiple elements to have the same "id" value.
Pointy
@michael i have written this just for readability exact requirement is a bit complex
Praveen Prasad
Yes, I understand multiple elements should not have the same `id`. I'm not sure how my answer suggested this.
Michael Mior