2

I am working on a big project and it is required to resend event to page.

Let me explain :

A box <div> is over an image <img> like this :

 <div>
   <div id="box"></div>
   <img>
 </div>

Once user clicks on the box, it moves to another location, but the image must be clicked in same time, these two elements must be clicked in same time. ( it is long to explain why )

Maybe it is possible to resend the event to the same location, or maybe is it possible to create another event at the current mouse position..

John
  • 7,500
  • 16
  • 62
  • 95

2 Answers2

1

You can try this:

$('selectorA').on('eventType', function(e){
    $('selectorB').trigger(e); // the SAME event
});

And without jQuery:

element.onSomeEvent = function(e){
   otherElement.dispatchEvent(e); // the SAME event
};

DOCs on dispatchEvent

Naftali
  • 144,921
  • 39
  • 244
  • 303
  • I think IE8 vs. every other browser requires different syntax. http://stackoverflow.com/a/827793/724626 – Joe Dec 24 '12 at 15:00
1

Why not call the click method on the image?

function OnclickOfBox()
{
    document.getElementById('imageID').click();
}

If you need to catch and pass the event parameter, that can be done fairly simply.

Vinod Vishwanath
  • 5,821
  • 2
  • 26
  • 40