-4

How could I achieve the following:

document.regTitle.innerHTML = 'hello';
Ahmed ibrahim
  • 33
  • 1
  • 2
  • 1
    What's wrong with what you have and what research have you done? This is easy to research in most any basic jQuery tutorial and in the api docs as well as in web search engine. [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – charlietfl Apr 22 '18 at 23:05
  • Welcome to StackOverflow! Have you tried anything so far? StackOverflow expects you to [**try to solve your own problem first**](http://meta.stackoverflow.com/questions/261592). Please attempt something, then update your question to show a **specific** problem you're having in a [**minimal, complete, and verifiable example**](http://stackoverflow.com/help/mcve). For further information, please see [**how to ask good questions**](http://stackoverflow.com/help/how-to-ask), and take the [**tour of the site**](http://stackoverflow.com/tour) :) – Obsidian Age Apr 22 '18 at 23:10
  • 3
    I'm voting to close this question as off-topic because Stackoverflow is not a free code conversion service and issue is easily researched – charlietfl Apr 22 '18 at 23:12
  • http://api.jquery.com/html/ boom done – Snowmonkey Apr 23 '18 at 01:11
  • Possible duplicate of [How to replace innerHTML of a div using jQuery?](https://stackoverflow.com/questions/1309452/how-to-replace-innerhtml-of-a-div-using-jquery) – Lece Apr 23 '18 at 01:44

2 Answers2

4

You should add this

$(function(){
    $('button').click(function(){
        $('span.regTitle').text('Span Text Replaced');
    });
});
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<span class="regTitle">Sample Content</span>
<br/><br/>
<button>Replace Span</button>
Anfath Hifans
  • 1,588
  • 1
  • 11
  • 20
0

$(function(){
$('#regTitle').html('this is a test');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div id="regTitle"></div>

Here's a snippet for jQuery innerhtml.

Wils
  • 1,178
  • 8
  • 24