dousi4472 2014-08-11 14:27
浏览 43
已采纳

加载的输入的值

I am trying to learn jQuery and Ajax. If I understand well, it is not possible to store the value of an input if that input is loaded. Is that correct?

index.php:

$("#content").load("proces.php");
    $(':button').click(function() {
        var dynamicValue = $('#inputfield').val();
        alert (dynamicValue);
});

process.php:

<input type="text" id="inputfield" />
  • 写回答

1条回答 默认 最新

  • dongpo9071 2014-08-11 14:33
    关注

    It is possible but you should wait for content to be loaded before reading Binding the event :

    $("#content").load("proces.php", function(){
        $('#myBtn').click(function(){
            var value = $('#inputField').val();
            alert(value);
        });
    });
    

    This suppose that your process.php contains something like

    <input type="text" id="inputfield" />
    

    And there is button with id myBtn in your HTML

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?