Javascript 用文本填充div

Javascript 用文本填充div,javascript,jquery,html,Javascript,Jquery,Html,我有一个div: <div id="shoppingBasket"> </div> 使用Javascript或Jquery,我将如何用默认文本填充: 您的购物篮中没有产品。 默认文本的意思是,我希望在他们单击产品后更改文本。因此,可能是变量中的默认文本,然后通过JavaScript或Jquery包含在div中,这将允许对变量进行操作 使用jQuery,这将是: $('#shoppingBasket').text("you have no products in yo

我有一个
div

<div id="shoppingBasket">
</div>

使用Javascript或Jquery,我将如何用默认文本填充:

您的购物篮中没有产品。


默认文本的意思是,我希望在他们单击产品后更改文本。因此,可能是变量中的默认文本,然后通过JavaScript或Jquery包含在div中,这将允许对变量进行操作

使用jQuery,这将是:

$('#shoppingBasket').text("you have no products in your shopping basket.");
使用常规javascript:

document.getElementById("shoppingBasket").innerHTML = "you have no products in your shopping basket.";

您可以使用jQuery或javascript来实现

使用jquery,使用jquery

使用Javascript,使用


怎么样?

默认文本是什么意思?我想阅读关于JQuery的基本教程可以帮助您了解这一点。
$('#shoppingBasket').text("you have no products in your shopping basket.");
document.getElementById("shoppingBasket").innerText = "you have no products in your shopping basket.";
function fillwithtext(text, elementID) {
    document.getElementById(elementID).innerHTML = text;
}