<div id='one'>one</div>
开发者_JS百科<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
$('#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'));
});
$('#two').click(function(){
Red({target: $('#one')[0]});
});
If all your div
s have the id
attribute set, why not just do $('#one')
to retrieve the div
in your function?
精彩评论