需要准备的材料分别有:电脑、浏览器、html编辑器。
1、首先,打开html编辑器,新建html文件,例如:index.html。
2、在index.html中的<script>标签中,输入js代码:
$('td').click(function () {
$('td').css('font-weight', 'normal')
$(this).css('font-weight', 'bold')
})
3、浏览器运行index.html页面,点击“我是A”,此时字体会变粗。
4、再点击“我是B”,此时“我是A”的字体粗度恢复正常,“我是B”的字体变粗。
因为你提到了点击,所以我猜想你那个文字应该是A标签。所以对A标签做了处理
代码如下:
<html><head>
<title> New Document </title>
<style type="text/css">
a{ //默认格式
font-size:10px //字体大小
font-weight:bold //加粗
color:#FF3030 //未点击过的颜色
text-decoration:none //去下划线
}
a:hover{ //鼠标移动上去的格式
color:#A020F0 //移动上去时的颜色
text-decoration:underline //移动上去时显示下划线
}
a:visited{ //访问过的样式
color:#A1A1A1 //访问过的颜色。
}
</style>
</head>
<body>
<a href="#">123</a>
</body>
</html>