# Seeking JavaScript for "surround selected text with formatting codes"

**URL:** <https://boards.straightdope.com/t/seeking-javascript-for-surround-selected-text-with-formatting-codes/965528>\
**Category:** Factual Questions\
**Created:** [June 1, 2022, 10:21pm UTC](https://boards.straightdope.com/t/seeking-javascript-for-surround-selected-text-with-formatting-codes/965528 "2022-06-01T22:21:34Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [June 2, 2022, 12:30am UTC](https://boards.straightdope.com/t/seeking-javascript-for-surround-selected-text-with-formatting-codes/965528/21 "2022-06-02T00:30:03Z")

</div>

That was the clue I needed. The PREVIOUS javascript def – for inserting smilies – didn’t have the close tag. It does now and now Brave is responding correctly when I click one of the formatting buttons!  
🙂

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [June 2, 2022, 12:31am UTC](https://boards.straightdope.com/t/seeking-javascript-for-surround-selected-text-with-formatting-codes/965528/22 "2022-06-02T00:31:11Z")

</div>

Good to hear. Yes, errors on line X often mean that there is really something wrong with line X-N.

Still, please fix that replace() function 🙂 .

[Previous page](https://boards.straightdope.com/t/seeking-javascript-for-surround-selected-text-with-formatting-codes/965528.md?page=1)
