0

jqueryで動的テーブルを表示する必要があります。テーブルデータをクリックすると、テキストフィールドの下に値が設定されます。

動的テーブルから名前をキャプチャしてテキスト フィールドに設定する方法を教えてください。

$(document).ready(function() {
    //Retrieve the JSON data from the server using AJAX
    $('#AJAXButton').click(function() {
        $.getJSON('ajax/ajaxtest.js', function(data) {
            processJSON(data);
        });
    });

    //Process and display the JSON data
    function processJSON(data) {
        var output = '<table><tr><th>Name</th><th>Platform</th></tr>';
        //Loop through the Languages 
        $(data.Languages).each(function(index, element) {
            output += '<tr><td class="clickable">' + element.Name + '</td>' + 
              '<td class="clickable">' + element.Platform + '</td></tr>';
        });
        output += '</table>';
        $('#AJAXDiv').html(output);
    }

    $("tr.clickable").live("click", function() {
            $("#name").append(?);
    });

});


<div id="AJAXDiv" style="width:400px; height:600px; background-color:#ddd; border:1px solid black">
</div>

<div>
    <label for="name">Created by: </label> <input id="name" />
</div>
4

2 に答える 2

0

このフィドルを見て、意図したものでない場合はお知らせください。

于 2011-08-30T21:43:09.797 に答える