gpt4 book ai didi

javascript - Bootstrap : Change text of small

转载 作者:行者123 更新时间:2023-11-28 11:16:07 24 4
gpt4 key购买 nike

我在使用 Twitter Bootstrap 和 jQuery 时遇到以下问题:

我有一个标题,采用 h1 格式,还有一个副标题,采用 small 格式。我想使用 jQuery 更改两者的文本。我的代码如下:

HTML:

<h1 id='h1id'>
Hello World
<br>
<small id='smallid'>Here I am!</small>
</h1>

JavaScript:

$(document).ready( function() {

$('#h1id').text('I can change this');
$('#smallid').text('But not this');

});

h1 已更改,但 small 元素消失。我该如何解决这个问题?

实例here

最佳答案

将 hello world 包裹在一个跨度中

HTML

<h1 id='h1id'>
<span>Hello World</span>
<br>
<small>Here I am!</small>
</h1>

JavaScript

$(document).ready( function() {
$('#h1id span').text('I can change this');
$('#h1id small').text('But not this');
});

关于javascript - Bootstrap : Change text of small,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28761455/

24 4 0