1

Ok so it sounds confusing... but in essence what im trying to do should make sense.

I am using jquery tabs. In these tabs I have some lists and some form fields.

so...

Tab a = list a with some form fields... Tab b = list b with formfields... and so on.

BUT... one of these tabs is an ALL tab. and it contains ListA and List B etc etc.

So my question is this.

If a user updates TAB A (list A) How can I get TAB C (all lists) to update with the same value?

Hope that makes sense.

Thanks in advance W

4

1 回答 1

2

这是一个带有一个输入的选项卡和一个带有所有输入的选项卡的示例。对任何输入的更改都会自动(在keyup事件中)发送到副本(即使您在“全部”选项卡(演示)上进行了更改:

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Nunc tincidunt</a>
        </li>
        <li><a href="#tabs-2">Proin dolor</a>
        </li>
        <li><a href="#tabs-3">Aenean lacinia</a>
        </li>
        <li><a href="#tabs-4">All</a>
        </li>
    </ul>
    <div id="tabs-1">
        <p>
            A:<input name='A' />
        </p>
    </div>
    <div id="tabs-2">
        <p>
            B:<input name='B' />
        </p>
    </div>
    <div id="tabs-3">
        <p>
            C:<input name='C' />
        </p>
    </div>
    <div id="tabs-4">
        <p>
            A:<input name='A' /><br/>
            B:<input name='B' /><br/>
            C:<input name='C' /><br/>
        </p>
    </div>
</div>
<script>
$(function () {
    $("#tabs").tabs();
    $('input[name=A],input[name=B],input[name=C]').on('keyup change', function() {
        $('input[name='+$(this).attr('name')+']').val($(this).val());
    })
});
</script>
于 2013-10-24T17:04:46.170 回答