gpt4 book ai didi

javascript设置字体粗细: want to set to bold or normal can't get it work

转载 作者:行者123 更新时间:2023-12-03 10:34:50 27 4
gpt4 key购买 nike

我似乎无法弄清楚如何获得 font-weight:bold;设置时,我想即时将设置更改为正常或粗体。有什么想法吗?

HTML

<li onclick="showStuff(this)" id="tabs1" style="margin: -5px 0px 0px 0px; padding: 0px 10px; border-width: 1px 1px 0px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-top-color: rgb(215, 215, 215); border-right-color: rgb(215, 215, 215); border-left-color: rgb(215, 215, 215); font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bold; font-stretch: inherit; line-height: 1.7em; vertical-align: baseline; list-style: none; position: relative; z-index: 99; display: inline-block; float: left; bottom: 0px; background: none 0px 0px repeat scroll rgb(250, 250, 250);"
class="design1"><a style="margin: 0px; padding: 6px 1px 6px 2px; border: 0px; font-family: Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: bold; font-stretch: normal; line-height: 18px; vertical-align: baseline; outline: 0px; color: rgb(0, 0, 0); text-decoration: none; display: inline-block; text-align: center; min-width: 140px;"
<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">
test1</span></a></li>

JavaScript。

<script type="text/javascript">
function showStuff(element) {
document.getElementById("tabs1").style.marginTop = "-5px"; // works fine.

document.getElementById("tabs1").style.fontWeight = "normal"; // doesn't work, tried various settings.
}

最佳答案

这是示例

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p:first").addClass("intro");
});
});
</script>
<style>
.intro {
font-size: 150%;
color: red;
}
</style>
</head>
<body>

<h1>This is a heading</h1>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Add a class name to the first p element</button>

</body>
</html>

关于javascript设置字体粗细: want to set to bold or normal can't get it work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29047577/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com