【发布时间】:2018-08-15 03:39:45
【问题描述】:
我只是想知道是否可以将具有相同类名的 div 中的文本复制到输入字段中
我正在尝试从具有相同类名的最后一个 div 中复制文本,然后粘贴到输入字段中,我该怎么做?
<div class="message">TEXT HERE</div>
<div class="message">TEXT HERE</div>
<div class="message">COPY THIS TEXT TO INPUT</div>
<div id="input_box" class="td_input">
<input type="text" name="content" id="content">
</div>
对不起我的英语不好
【问题讨论】:
-
i am trying是的,可能有办法,您自己尝试过吗?请张贴代码 -
把它分成几个步骤,你应该能够很容易地研究自己的答案! (1) Get the last element of a certain class (2) Get the text from that element (3) Populate the input
标签: javascript html