Using jQuery, how do I change the elements html value? (div)

前端 未结 8 1654
孤街浪徒
孤街浪徒 2020-12-16 16:43

Using a ajax request I want to change content of my div.

202

So I want to change the content to a differen

8条回答
  •  一个人的身影
    2020-12-16 17:13

    $("#di").html('My New Text');
    

    Check out the jQuery documentation.

    If you wanted to increment the number, you would do

    var theint = parseInt($("#di").html(),10)
    theint++;
    $("#di").html(theint);
    

    P.S. Not sure if it was a typo or not, but you need to include the # in your selector to let jQuery know you are looking for an element with an ID of di. Maybe if you come from prototype you do not expect this, just letting you know.

提交回复
热议问题