About the Javascript replace Function

Asked 1 years ago, Updated 1 years ago, 32 views

I used the replace function for the script.
Does the type not match?
It doesn't work well.Even if you look at various sites,
I don't know how to handle it carefully. Please point out the point of misuse.
I would appreciate it if you could post the URL of the reference site.

<html>

<head>
  </head>

<body>
  <br of >
  <form name="js">
    <input name="a" type="text"/>x+<input name="b" type="text"/>y=<input name="c" type="text"/>
    <br of >
    <input onclick="calculate()" type="button" value="Calculate"/>
    <br of >
    <input onclick="clr()" type="button" value="erase"/>br/>
  </form>
  <span id="a"></span>x+<span id="b">/span>y="c">
    </span>
  <script>
    function calculate(){   
      vard = new Array(4);    
      var stringa;   
      d[0] = document.js.a.value;    
      stringa=d[0].replace(/&g, '&amp');    
      document.getElementById("a").innerHTML=stringa;
    }
  </script>
  </body>

</html>


    

javascript html

2022-09-30 19:24

1 Answers

The questioner said, "It doesn't work," but it looks like it's working on Internet Explorer or Google Chrome.

stringa=d[0].replace(/&g, '&');

The correct one should be & instead of &.See text entity


2022-09-30 19:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.