-2

Looks like something is wrong with my code? HTML won't run it. When I click the button element in HTML the font size does not change. What am I missing?

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
  $(document).ready(function() {
    $("button").css("font-size", "5em");
      });
  </script>
Sean
  • 21
  • 6

1 Answers1

0

You can't give a <script> tag both a src and content. It's one or the other.

You need this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
  $(document).ready(function() {
    $("button").css("font-size", "5em");
  });
</script>
user229044
  • 232,980
  • 40
  • 330
  • 338
  • Is it suppose to look like this? – Sean Aug 24 '20 at 13:22
  • @sean Yes, as I said in my answer. – user229044 Aug 24 '20 at 13:23
  • One more question: Thank you. Last question on this topic: I am trying to add this to an external file. Is this correct? If not what is the correct way? My HTML file: ~script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> My external JQ file: $(document).ready(function(){ $("button").click(function(){ $("button").hide(); }) }); – Sean Aug 24 '20 at 14:03
  • I also added a cleaner version in your previous comment with example to me – Sean Aug 24 '20 at 14:10