如何在页面加载之前加载此jQuery

时间:2019-06-29 04:27:19

标签: jquery

如何将其更改为而不是在鼠标悬停时更改,我希望代码在页面加载之前替换以下输入。

  $("#fieldsample").mouseover(
    function() {
      $("#input_12_1").val(jQuery(this).val().replace(/(<([^>]+)>)/ig, ""))
    }
  );

});
<input type="text" value="<DT></DT><DD>content</DD>" id="fieldsample" name="lname">

1 个答案:

答案 0 :(得分:0)

在下面更改您的jslike

$("#fieldsample").mouseover(function () {
  var val = jQuery(this).val().replace(/(<([^>]+)>)/ig, "");
  $("#input_12_1").val(val);
});

$("#fieldsample").mouseover(function () {
  var value = jQuery(this).val().replace(/(<([^>]+)>)/ig, "");
  $("#input_12_1").val(value);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" value="<DT></DT><DD>content</DD>" id="fieldsample" name="lname"/>

<input type="text" value="" id="input_12_1"/>

相关问题