0
我的代碼適用於文本框中的單行輸入。例如:name:adam
使用javascript將多個數據從文本框抓取到文本框中
但我想要的是,當我將數據輸入到文本框時抓住名稱和類。事情是這樣的:
例子:
name:adam
class:8th grade
<script>
function myFunction()
{
var x = document.getElementById("tarea");
document.getElementById("name").value = x.value.substring(5);
}
</script>
而在HTML部分,我有這樣的:
<textarea rows="4" cols="50" id="tarea" onblur="myFunction()"></textarea>
name: <input type="text" id="name"></br>
class: <input type="text" id="class">
我用你的方法在這裏的http:/ /jsfiddle.net/irfan/c2LRj/但沒有得到所需的結果。請告訴我我哪裏錯了。 –
嘿抱歉,我沒有做整個事情只是選擇你需要的數據。用工作小提琴和額外的代碼 – Evan
感謝我的答案udpating我的答案。有效 –