我想把我的一部分文字加粗,比另一部分文字大。但目前我使用的jquery文本的大小、字号和颜色都是一样的。例如,在下面的代码中,我希望“硬盘驱动器:辅助存储设备”出现。我希望硬盘驱动器是粗体字和标题。我要另一半正常的字体重量更小。如何在jquery或css中使用我拥有的代码来设计这个样式?:)
如果你能帮忙,我将不胜感激!
以下是我的j查询:
$('#harddrive').hover(function() {
$('#info').text('Hard drive: Secondary Storage Device');
}, function() {
$('#info').text('');
});
$('#cd').hover(function() {
$('#info').text('CD: External Secondary Storage Device');
}, function() {
$('#info').text('');
});
$('#fan').hover(function() {
$('#info').text('Fan: Used to keep the computer cool');
}, function() {
$('#info').text('');
});
$('#powerblock').hover(function() {
$('#info').text('Power Block: Provides power to the computer');
}, function() {
$('#info').text('');
});
最佳答案
您需要更改HTML并使用.html()
而不是.text()
。
例如:
$('#info').html('<h3>Hard drive:</h3> Secondary Storage Device');