I have the following:
我有以下內容:
<div id="info-message"></div>
I am changing the text in between the DIVs like this:
我正在更改DIV之間的文本,如下所示:
$('#info-message').html = "xxx";
However even though I can step through this in the firebug debugger I don't see any change on the screen and nothing is added when I look with firebug.
然而,即使我可以在firebug調試器中逐步執行此操作,但我在屏幕上看不到任何更改,並且當我查看firebug時沒有添加任何內容。
5
Because html
is a method, you need to call it like one:
因為html是一個方法,你需要像下面一樣調用它:
$('#info-message').html("xxx");
Currently, you are setting the html
property of the jQuery object to the string "xxx".
目前,您正在將jQuery對象的html屬性設置為字符串“xxx”。
3
The correct usage of the html()
jQuery method is:
html()jQuery方法的正確用法是:
$('#info-message').html("xxx");
And in case you wanted to retrieve the html of an element:
如果你想檢索一個元素的html:
$('#info-message').html();
2
$('#info-message').html('xxx')
2
You must use html()
method:
你必須使用html()方法:
$('#info-message').html("xxx");
and if you want to append an element and work with its DOM you can use the following:
如果你想附加一個元素並使用它的DOM,你可以使用以下代碼:
var contentDiv = $('<div class="content">xxx</div>');
$('#info-message').append(contentDiv);
contentDiv.css('color', 'red');
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/04/11/f21d111d87b179d94f19af9907ff6b39.html。