Skip to content Skip to sidebar Skip to footer

Fill Div With Text

I have a div:
Using Javascript or Jquery how would I fill this with the default text: you have no products in your shopping basket. Wh

Solution 1:

You can do it using jQuery text() or javascript innerText

With jquery, using jQuery text()

$('#shoppingBasket').text("you have no products in your shopping basket.");

With Javascript, using innerText

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

Solution 2:

With jQuery this would be:

$('#shoppingBasket').text("you have no products in your shopping basket.");

with regular javascript:

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

Solution 3:

functionfillwithtext(text, elementID) {
    document.getElementById(elementID).innerHTML = text;
}

How's that?

Post a Comment for "Fill Div With Text"