jQuery的附加文字 [英] jQuery append text
问题描述
我要像一个div追加一些简单的数据:
$('#味精')追加('一些文本')。
在身,我想我会需要放置的HTML等。
< DIV ID =测试>< DIV ID =味精>< / DIV> //显示它里面的文字。< / DIV>
不过,我想一些CSS添加到 #msg
。例如,背景颜色。现在的问题是,既然 #msg
DIV是present一切的时候,我看到即使在文本不附加到它的背景颜色。我尝试添加CSS像显示:无,但在这种情况下,我无法看到的文本追加到它。
我能做到这一点,使 #msg
DIV内出现只有当文本被追加到它#TEST
?谢谢你。
$('#味精')追加('一些文本)显示()。
I want to append some simple data in a div like:
$('#msg').append('Some text');
In the body, i think i will need to place the the html like.
<div id="test">
<div id="msg"></div> //show text inside it.
</div>
However, I want to add some CSS to the #msg
. For example, background color. Now the problem is that, since the #msg
div is present all the time, i see the background color even when the text is not appended to it. I have tried to add css like "display:none, but in that case i can not see the text appended to it.
Can i do it so that the #msg
div appears inside the #test
only when the text is appended to it? Thanks.
$('#msg').append('Some text').show();
这篇关于jQuery的附加文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!