1

Please guys I want to replace a HTML string using JavaScript but its not working $("#div_id").HTML($("#div_id").html().replace (/<<(.*?)>>/g, "{{$1}}")); I know am getting something wrong, any help?

1
  • String is replaces but updated string is not applied... Use .html(UpdatedStriing) Commented May 4, 2016 at 6:39

1 Answer 1

2

Declare updated html in a variable and then apply it as a new html

var newHTML = $("#div_id").html().replace (/<<(.*?)>>/g, "{{$1}}");

$("#div_id").html(newHTML);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.