Timeline for jQuery replace HTML
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 6, 2017 at 6:25 | answer | added | Marc Rohloff | timeline score: 1 | |
Jul 6, 2017 at 6:24 | answer | added | Tushar | timeline score: 1 | |
Jul 6, 2017 at 4:15 | history | edited | Tushar | CC BY-SA 3.0 |
Trademark capitalization; acronym capitalization; layout; Added [jQuery].
|
Jul 5, 2017 at 20:37 | comment | added | Barmar | Oops, I misremembered. | |
Jul 5, 2017 at 20:35 | comment | added | Cody Geisler | api.jquery.com/text/#text-function but it's not D: ! | |
Jul 5, 2017 at 20:31 | comment | added | Barmar |
It should be (e) => . The first argument is the old text.
|
|
Jul 5, 2017 at 20:31 | review | Close votes | |||
Jul 8, 2017 at 13:27 | |||||
Jul 5, 2017 at 20:26 | comment | added | Cody Geisler |
Oh jeez I guess it pays to read the documentation once in a while; but I wouldn't have guessed I could apply a selector to each of the texts independently like you suggested without each. So this just becomes $('[id^="mytext-text"]').text((i,e)=>e.replace(/\n/gm,'<br>')) !
|
|
Jul 5, 2017 at 20:17 | comment | added | Barmar |
The argument to .text() and .html() can be a function. It receives the old text/html as an argument, and returns the replacement. You don't need .each() , since it automatically loops, and calls the function for each element.
|
|
Jul 5, 2017 at 18:37 | history | asked | Cody Geisler | CC BY-SA 3.0 |