请检查下面的代码,如果有帮助:http://jsfiddle.net/La2y734g/2/
HTML如下
<textarea id="Input" cols="50" rows="5">This textbox has been given a name of "myTextBox". This can be used by any script that process the contents of this textbox (once it's been submitted to the server).</textarea>
<br>Replace
<input type="text" id="replace">with
<input type="text" id="with">
<button>Detect Single Letters And Replace</button>
JavaScript作为弗洛WS
$("button").on("click", function() {
//$("#Input").replaceWith($("Change") );
var toReplace = $('#replace').val();
var withText = $('#with').val();
var newText = $("#Input").val().replace(toReplace, withText);
$("#Input").val(newText);
});
你能发布您的代码,所以我们可以清楚地看到你尝试过什么? – Gjohn 2014-09-10 21:41:53
http://jsfiddle.net/clarinetking/6cLgghme/此外,我知道变化不是一个有效的项目,因为它不是一个div或类似的东西(可能是某个奇特的术语) – Clarinetking 2014-09-10 21:42:54
更新:显示我的意思是更好: http://jsfiddle.net/clarinetking/6cLgghme/1/ – Clarinetking 2014-09-10 21:49:06