tags:

views:

33

answers:

2

I have the following code:

    $('#Element1').event(function() {
        $('#Element2').event({ prop: $('#Element1').someMethod() });
    });

Now the Element 2 responds on an Event of Element1 and when Element 1 property changes. How to do it vice-versa in an optimum manner.

A: 

I think this would be the easiest solution:

$("#textbox1").keyup(function() { $("#textbox2").val($(this).val()); });
$("#textbox2").keyup(function() { $("#textbox1").val($(this).val()); });
Philippe Leybaert
ok, you were first ;)
Fabian Neumann
A: 

For the problem you describe in your comment, I don't think you'd need such complicated event-driven code. Here's my solution:

$("#input1, #input2").keyup(function (e) {
    $("#input1, #input2").val($(this).val());
});
Fabian Neumann