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

前端 未结 8 1666
孤街浪徒
孤街浪徒 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:20

    if your value is a pure text (like 'test') you could use the text() method as well. like this:

    $('#d1').text('test'); Or $('#d1').html('test');
    

    anyway, about the problem you are sharing, I think you might be calling the JavaScript code before the HTML code for the DIV is being sent to the browser. make sure you are calling the jQuery line in a

提交回复
热议问题