Get the contents out.



  • There's such a long html:

        <div id="selection"></div>
    <div id="sel">
        <tr>
            <td><input type="radio" name="name_inp" value="val1" id="val1"></td>
            <td><label for="val1"><nobr><span>first label</span></nobr></label></td>
            <td><label for="val1"><nobr>second label</nobr></label></td>
            <td><label for="val1"><nobr>third label</nobr></label></td>
            <td><label for="val1">fourth label</label></td>
        </tr>
        <tr>
            <td><input type="radio" name="name_inp" value="val2" id="val2"></td>
            <td><label for="val2"><nobr><span>first label</span></nobr></label></td>
            <td><label for="val2"><nobr>second label</nobr></label></td>
            <td><label for="val2"><nobr>third label</nobr></label></td>
            <td><label for="val2">fourth label</label></td>
        </tr>
        <tr>
            <td><input type="radio" name="name_inp" value="val3" id="val3"></td>
            <td><label for="val3"><nobr><span>first label</span></nobr></label></td>
            <td><label for="val3"><nobr>second label</nobr></label></td>
            <td><label for="val3"><nobr>third label</nobr></label></td>
            <td><label for="val3">fourth label</label></td>
        </tr>
    </div>
    

    And the question is radioto remove the third label and the fourth label and place it in the first place. div? Text generates phpI don't want to touch a unique meaning. Applicable. next()I don't think that's the case. Something. filter()? I can't figure it out better.

    The value is as follows:

    var val_sel = $('#sel input:radio:checked').val();
    


  • Is that okay?

    $(document).ready(function() {
        $('input[type=radio]').bind('click', function() {
            $('#selection').html($('label[for="' + $(this).val() + '"]').eq(2).html());
        });
    });
    

    I'll explain:
    $('label[for=' + $(this).val() + ']') - Looking for all the tags. labelrelevant value selected radio
    .eq(2) - takes the third one.
    .html() - separates his contents.
    $('#selection').html([что-то]) - It's coming. [что-то] inside the component id=selection




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2