I am trying to Replace Old Values with New Values in P Tag By Using JQuery replace(String SearchValue, String replaceValue) Method on buton click. if I pass Fixed Values then it update but when I Pass through input text Box then it doesn't.
I used Different method to Solve this problem even tried on internet but no salutation .
<div class="container">
<div class="row">
<input type="text" value="" id="TxtOne" name="TxtOne" placeholder="Old Word" class="form-control" />
</div>
<div class="row">
<input type="text" value="" id="TxtTwo" name="TxtTwo" placeholder="New Word" class="form-control" />
</div>
<div class="row">
<input type="button" onclick="ChangeData();" class="btn btn-primary" value="Update" id="btnOne" name="btnOne" style="float:right" />
</div>
</div>
I want to replace hate with Love
<script>
function ChangeData() {
var oldData = $('#TxtOne').val();
oldData = '/' + oldData + '/ig';
var newData = $('#TxtTwo').val();
var $p = $('p');
$p.text($p.text().replace(oldData, newData));
//$p.text($p.text().replace(/hate/ig, 'love'));
};
</script>
No Result