如何使用 jQuery 替换 div 的 innerHTML?

我如何实现以下目标:

document.all.regTitle.innerHTML = 'Hello World';

使用 jQuery,其中regTitle是我的 div ID?

答案

$("#regTitle").html("Hello World");
$('#regTitle').html('Hello World');
$('#regTitle').text('Hello world');
var itemtoReplaceContentOf = $('#regTitle');
itemtoReplaceContentOf.html('');
newcontent.appendTo(itemtoReplaceContentOf);
$('#regTitle').empty().append(newcontent);
//This is the setter of the innerHTML property in jQuery
$('#regTitle').html('Hello World');

//This is the getter of the innerHTML property in jQuery
var helloWorld = $('#regTitle').html();
$("#regTitle").html('Hello World');
$('#regTitle').fadeOut(500, function() {
    $(this).html('Hello World!').fadeIn(500);
});
function changeInnerHtml(elementPath, newText){
    $(elementPath).fadeOut(500, function() {
        $(this).html(newText).fadeIn(500);
    });
}
$("#regTitle").html("hello world");
$("#regTitle").text("hello world");
var contents = $(element).html();
$(element).html("insert content into element");

$( document ).ready(function() {
  $('.msg').html('hello world');
});
<!DOCTYPE html>
    <html>
      <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>    
      </head>
      <body>
        <div class="msg"></div>
      </body>
    </html>

$("#regTitle")[0].innerHTML = 'Hello World';