javascript setTimeout无法正常工作

问题描述

我想要的是一个将参数更改为粗体的按钮,并在5秒钟后刷新了整个页面在这里查看我的代码。但是正在发生的是它变得粗体并且页面正在刷新不到一秒钟。

var btn = document.getElementById('button_1');
var para = document.getElementById('content');
btn.addEventListener('click',function ab()  {
    //Change the font weight style to 700
    para.style.fontWeight = '700';
  });
btn.addEventListener('click',function aq()  {
    
    setTimeout(location.reload(),5000);
  });
<!DOCTYPE html>
<html>
<head>
    <title></title>
    
</head>
<body>
<p id="content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unkNown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,but also the leap into electronic typesetting,remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<table border="1">
    <tr>
        <td>
            Press the following buttons to make changes accordingly.
        </td>
    </tr>
    <tr>
        <td><button id="button_1" >Bold</button></td>
        <td><button id="button_2">underline</button></td>
        <td><button id="button_3">Align to left</button></td>
        <td><button id="button_4">Align to right</button></td>
    </tr>   
    <tr>
            <td><button id="button_5">Align to center</button></td>
            <td><button id="button_6">Align as justified</button></td>
            <td><button id="button_7">Uppecase</button></td>
            <td><button id="button_8">Lowercase</button></td>


    </tr>
        

    
</table>
<script src="a1.js"></script>
</body>
</html>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)