javascript - Replace text with textbox contains this text -


i have html document contains text, assume there 1 word in each line in document, want replace each word textbox contains word. there easy way (in javascript)? practical example:suppose have html document contains table contains grade, , there cell contains average, want replace every grade textbox , let user edit grades calculate new average

assuming these words in div, here's how approached problem jquery (sorry if looking pure js)

html

<div>these yours words. want split of these new textboxes</div> 

jquery

var currenttext = $("div").text(); var arrwords = currenttext.split(" ");  $("div").empty(); var newhtml = "";  (var = 0; < arrwords.length; i++) {     newhtml += "<input type='text' value='" + arrwords[i] + "'/><br/>"; }  $("div").append(newhtml); 

heres fiddle: http://jsfiddle.net/seyqu/2/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -