-3

What should i do if i need to replace the "test test" message with custom one using JavaScript?

<div class="outputmsg_container" style="" id="output_messages"><
    button class="btn btn-icon close icon-cross" onclick="GlideUI.get().clearOutputMessages(this); return false;">
        <span class="sr-only">Close Messages"</span>
            </button>
            <div class="outputmsg_div">
                <div class="outputmsg outputmsg_error notification notification-error"><img class="outputmsg_image" src="images/outputmsg_error_24.gifx" alt="">
                <span class="outputmsg_text">test test</span>
                    </div>
                    </div>
                    </div>
j08691
  • 204,283
  • 31
  • 260
  • 272
Vignesh M
  • 1
  • 2

3 Answers3

0

Use innerHTML to change the HTML inside an element.

<label for="newhtml">HTML (or text) to be inserted inside div:</label>
<br/>
<input type="text" id="newhtml"/>
<br/>
<input type="button" id="change" value="Insert" onClick="change()"/>
<br/>
<span id="container"></span>
<script>
function change(){
    document.getElementById("container").innerHTML = document.getElementById("newhtml").value;
}
</script>
-1

Here is an example to do this with jquery.

$('.outputmsg_text').html("YOUR CUSTOM TEXT")
Clujio
  • 332
  • 1
  • 6
  • They did not specify that they have jQuery (and a pure JS answer is very simple for something like this) – Marie Jul 11 '18 at 17:09
-1

Here's an example JSFiddle (REQUIRE JQUERY)

<button id="change">Change Text</button>
    <div id="div">
    Some text
    </div>
    <script>
    $("#change").click(function(){
      var name = prompt("What text shoud it be?");
      if(name){
        $("#div").html(name);
      }
    });
    </script>
  • They did not specify that they have jQuery (and a pure JS answer is very simple for something like this) – Marie Jul 11 '18 at 17:09