如何更改< span>中的文本用jQuery? [英] How can I change the text inside my <span> with jQuery?

查看:93
本文介绍了如何更改< span>中的文本用jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的问题,但这是我以前从未做过的事情.我有以下内容:

I have a really simple question but it's something I have not done before. I have the following:

<td id="abc" style="width:15px;"><span></span></td>

我想在范围内输入一些文字.

I would like to put some text into the span.

我该如何使用jQuery.我知道如何更改ID为abc的内容,但不更改范围内的代码.

How can I do this with jQuery. I know how to change things with the id of abc but not the code inside the span.

谢谢

推荐答案

$('#abc span').text('baa baa black sheep');
$('#abc span').html('baa baa <strong>black sheep</strong>');

text()(如果只是文本内容). html()(如果其中包含html内容).

text() if just text content. html() if it contains, well, html content.

这篇关于如何更改&lt; span&gt;中的文本用jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆