請檢查下面的代碼,如果有幫助: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