如何将左侧文本字段数据存储到右侧文本字段中

时间:2017-02-08 11:43:15

标签: javascript php

  

how to i am storing left text field data into right text field. i am copy past numbers in a left side text field and then press add button the numbers of left side text field are store (appear) in right side text field the numbers are past in this format 123456 123456 234516. it is possible.

[这是文本字段的设计] [1] [1]:https://i.stack.imgur.com/jj4Ju.png

1 个答案:

答案 0 :(得分:0)

如果我正确理解了您的问题,您只想将左侧文本区域的内容复制到右侧,对吧?这是一个简单的解决方案:

var
    taLeft = document.getElementsByClassName('left')[0],
    taRight = document.getElementsByClassName('right')[0],
    btn = document.getElementsByClassName('btn')[0];

    btn.addEventListener('click', function() {
       taRight.value = taLeft.value;
    })

这是有效的demo