https://codepen.io/hopefulcodegirl/pen/MWyXLry?editors=1100

Can someone please tell me why my code isn’t working? When I click, my search button should turn into basically a search bar.

You’re really close on this one. This is breaking because “text/javascript” is the type of script your making, not the src. Updating this to type=“text/javascript” will fix the issue. However, I would recommend you remove this attribute entirely. If you’re working in standard HTML, scripts always default to javascript. If you’re working in something like XHTML, then you’ll have to include it, but otherwise it’s just extra text!

Edit: I’m not sure I specified the problem area very well. Sorry about that. The issue is in your element where the click function is created. Your script element looks like this…

<script src="text/javascript">
      $(document).ready(function() {
        $('.icon').click(function() {
          $('.search').toggleClass('active')
        })
      })
  </script>

Removing the src attribute from the script element, or updating it to the type attribute, will fix the issue.

<script>
      $(document).ready(function() {
        $('.icon').click(function() {
          $('.search').toggleClass('active')
        })
      })
</script>

Hope this helps.

1 Like

Thank you so much! It worked!

1 Like