Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for javascript:Using the replace() to replace text in html

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Nov 13, 2013 at 15:52 comment added Wagner Leonardi dude, you are using replace() function wrong! you aren't replace anything since you are giving the same string in parameter. I made a reply explaining that. To change a value you don't need to use replace(), just set document.getElementById('str').innerHTML= "text". Easy as that.
Nov 13, 2013 at 15:40 answer added Wagner Leonardi timeline score: 1
Nov 13, 2013 at 15:39 comment added user2390516 function myFunction(){ var str = document.getElementById('str').innerHTML="Is this all there is?"; var replace = str.replace(str, "Is this all?!") document.getElementById('str').innerHTML= replace; }
Nov 13, 2013 at 15:38 answer added Juan Garcia timeline score: 1
Nov 13, 2013 at 15:36 answer added 最白目 timeline score: 0
Nov 13, 2013 at 15:35 comment added Juan Garcia str should replace something in the tet you have, it cannot replace anything if there is anything to replace, wht you are asking is to append the text to the current text.
Nov 13, 2013 at 15:33 comment added Juan Garcia You want the result to be "Is this all there is? Is this all?!" or what you want the result to be?
Nov 13, 2013 at 15:32 comment added user2390516 Its only outputs Is this all there is? when the button is clicked I'm trying to add is this all?! to the end of that. But I need to use the Replace() method.
Nov 13, 2013 at 15:30 comment added 最白目 how is the behaviour now / what is not working?
Nov 13, 2013 at 15:27 history asked user2390516 CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /