如何检查元素的值是否已更改?

时间:2018-11-21 09:16:40

标签: jquery asp.net-mvc razor

如何使用Javascript或jQuery检查Html.EditorFor元素的值是否已更改?

@Html.EditorFor(model => model.AddressPhysical1, new { htmlAttributes = new { @class = "form-control", id = "AddrPhys1", @onload = "TrackChanges(this.value)" } })
$(document).ready(function TrackChanges() {
  var address = $('#AddressPhysical1').val();

  $('#AddressPhysical1').keyup(function() {
    if ($('#AddressPhysical1').val() != content) {
      content = $('#AddressPhysical1').val();
      alert('Content has been changed');
    }
  });
});

0 个答案:

没有答案