0

I am trying to extract the textbox value and send it to server but when I paste something in the var sd=$('#TextBoxUrl').val(); does not get the data on first paste event when I paste again then it gets the date from the textbox. What can be the problem?

$('.urldetailstextbox').bind('paste', function () {
    $("#DivUrlDetails").data('ready', false);
    divprogress.style.display = "block";
    DivUrlDetails.style.display = "none";
    $('#spandetail').append();
    $('#spanurl').append();
    $('#spantitle').append();
    var sd = $('#TextBoxUrl').val();
    $("#divlinksave").data('requesting', true);
    console.log(sd);
}
4

1 回答 1

0

您必须捕获 paste 事件并稍等片刻才能填充 val。

https://stackoverflow.com/a/1503425/336542

$('input').bind('paste', function () {
  var element = this;
  setTimeout(function () {
    var text = $(element).val();
    // do something with text
  }, 100);
});
于 2013-05-11T19:38:55.077 回答