How to replace a charcter within a text For instance
<script>alert("Hi i am nishant");</script>
here i want to replace < and > by ASCII code so how i will replace it.
The replaceAll() method is an inbuilt method in jQuery which is used to replace selected elements with new HTML elements. Parameters: This method accepts two parameter as mentioned above and described below: content: It is the required parameter which is used to specify the content to insert.
The Java String class replace() method returns a string replacing all the old char or CharSequence to new char or CharSequence.
text(). replace('-', ''); jquery.
We can replace HTML elements using the jQuery . replaceWith() method. With the jQuery replaceWith() method, we can replace each element in the set of matched elements with the provided new content and return the set of elements that were removed.
var text = text.replace(/</g, "<").replace(/>/g, ">");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With