如何使用jQuery替换div的innerHTML?

JavaScript

番长十三

2020-03-16

我如何实现以下目标:

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

使用jQuery regTitle我的div ID 在哪里

第1644篇《如何使用jQuery替换div的innerHTML?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

3个回答
LEYJim 2020.03.16

jQuery has few functions which work with text, if you use text() one, it will do the job for you:

$("#regTitle").text("Hello World");

Also, you can use html() instead, if you have any html tag...

小卤蛋Pro 2020.03.16

you can use either html or text function in jquery to achieve it

$("#regTitle").html("hello world");

OR

$("#regTitle").text("hello world");
LSam 2020.03.16
$("#regTitle").html("Hello World");

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android