Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在表单中,当文档准备好时,我正在尝试使用 jQuery 将文本框的预设值复制到另一个文本框。我试过 $("#b").val() = $("#a").val();了,但它不起作用。请参考this fiddle。
$("#b").val() = $("#a").val();
你会用这个:
$(document).ready(function() { $("#b").val($("#a").val()); });
试试这个,
$(function() { $("#b").val($("#a").val()); });
或者你可以这样做:
$(function() { $("#b")[0].value = $("#a")[0].value; }