0
 jQuery.ajaxSettings.traditional = true;
 $(document).ready(function(){
        $(".wijstoe").change(function(){
            var id = $(this).children('#test').map(function() {
             return $(this).text();
            }).get();
            var mw = $("option").val();
            var opg = "Opgeslagen !";
            $("#loading").css("display","block");
            $.post("wijstoe.php",
                {mw:mw, id:id},
                function(data,status)
                {       
                    $("#loading").css("display","none");
                    $(this).children('#tester').html(opg);                                          
                });
        });
    });

HTML/PHP:

                        echo "<td>$row[2]</td>";
                        echo "<td id='test1'>";
                        echo "<div class='wijstoe'>";
                        echo "<div id='test' style='display:none;'>".$row[0]."</div>";
                        echo "<form><select>";
                        if($_SESSION['uname'] == 'admin') {
                            $querya="select uname from users";
                            $resulta = mysql_query($querya);
                            while ($rowa = mysql_fetch_row($resulta)) {
                            echo "<option>".$rowa[0]."</option>";
                                    }
                        echo "</select></form>";
                        echo "<div id='tester'>DIDI</div>";
                        echo "</div>";
                        echo "</td>";
                        }

これは、テキスト opgeslagen に置き換えられた ID テスター (DIDI) からのテキストを取得しません。

$(this) を使用しない場合は機能しますが、id テスターを持つすべての div で機能します。この特定の div のテキストを置き換えたいだけです。

したがって、これは機能します:

  $(this).children('#tester').html(opg);          

これは動作しません :

  $('#tester').html(opg);          
4

2 に答える 2

0

試す

$(this).find('#tester').html(opg);    
于 2013-09-06T15:45:29.573 に答える