1

I'm using accordion jQuery UI , in each accordion there are some fields, I want to be able to change each accordion Title by using the first input[type=text] of each accordion

This JS which I wrote, but only work for the first input[type=text] of the first accordion and I want for each accordion

$('.redux-groups-accordion-group input[type=text]:first').live('keyup',function(event) {
     $(this).parents('.redux-groups-accordion-group:first').find('.redux-groups-header').text(event.target.value);
});

HTML :

<div id="redux-groups-accordion">
    <div class="redux-groups-accordion-group">
        <h3 class="ui-accordion-header">
            <span class="redux-groups-header">New Slide Title</span>
        </h3>
        <div class="ui-accordion-content">
            <input type="hidden" name="id" />
            <input type="text" name="title" />
            <input type="text" name="tags" />
        </div>
    </div>
    <div class="redux-groups-accordion-group">
        <h3 class="ui-accordion-header">
            <span class="redux-groups-header">New Slide Title</span>
        </h3>
        <div class="ui-accordion-content">
            <input type="hidden" name="id" />
            <input type="text" name="title" />
            <input type="text" name="tags" />
        </div>
    </div>
</div>
4

2 に答える 2

0

デモ http://jsfiddle.net/v7XgA/

ちなみにlive非推奨です:

私はあなたがJqコードで使用していた.on代わりに使用していたので、すべてを取り除くことを目指していましたlive:first:first

休息は必要に応じて行う必要があります:)

これを試して

$('.redux-groups-accordion-group input[type=text]').on('keyup',function(event) {
     $(this).parents('.redux-groups-accordion-group:first').find('.redux-groups-header').text(event.target.value);
});
于 2013-10-18T02:21:11.517 に答える
0

試す

$('#redux-groups-accordion').on('keyup', '.redux-groups-accordion-group input[name="title"]', function (event) {
    $(this).closest('.redux-groups-accordion-group').find('.redux-groups-header').text(this.value);
});

デモ:フィドル

于 2013-10-18T02:22:32.360 に答える