我试图让文字(胖)变粗。 Curretly我设法在下面执行以下代码:
Movie <b>fat</b> was been added
但是这个粗体标签不起作用。现在问题是如何只为(胖)启用html,像这样大胆:Movie
胖 was been added
到目前为止我的代码:
var boldy = (Movie[0].title)
var fat = boldy.bold()
$("div.container div:first").text("Movie " + (fat) + " was been added")
我也尝试过这个:
$("div.container div:first").html("Hello <b>"+(boldy)+"</b>")
答案 0 :(得分:1)
您可以使用以下内容:
$("div.container div:first").css("font-weight","Bold");
这会将属性 font-weight 从该div更改为粗体。
@EDIT:您可以创建一个带有ID的div,并在jQuery上提到该ID:
$("div.container div:first div#text").css("font-weight","Bold");
答案 1 :(得分:1)
var world = 'world';
$("div").html(`Hello <b>${world}</b>`);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
Movie fat was been added
</div>
答案 2 :(得分:1)
var word ="fat"
$("div:first").html("Movie <b>"+word+"</b> was been added")
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div></div>
&#13;
答案 3 :(得分:0)
var html = $("div.container div:first").html;
$("div.container div:first").html(html.replace(/fat/gi, '<strong>$& </strong>'));