看起来你的代码工作正常
<!DOCTYPE html>
<html>
<head> </head>
<body>
<button id="button1">image</button>
<p id="dropdown">Hello bob</p>
<script>
function openNav() {
document.querySelector('#dropdown').style.color = 'red';
}
document.getElementById('button1').addEventListener('click', openNav);
</script>
</body>
</html>