Ask coding questions

← Back to all posts
Javascript is not working
lolguineapig (26)

I am trying to make a SIMON game, but my JS is not working. I tried using a JS file, but that did not work. So then I tried using the <script> tag in my HTML... and that did not work either. Here is my code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1 class="simonStatus">Press any key to start!</h1>
<br>
<br>
<div id="simongrid">
<button class="green">&nbsp;</button>
</div>
<script type="text/javascript">
var greenWidth = $('.green').width();
$('.green').css({'height', greenWidth + 'px'});
</script>

Thanks!

Answered by ch1ck3n (2340) [earned 5 cycles]
View Answer
Comments
hotnewtop
ch1ck3n (2340)

line 10 should be $('.green').css('height', greenWidth + 'px');

lolguineapig (26)

@ch1ck3n Thanks so much :) the strange part was that when I did $('.green').css({'height', greenWidth + 'px'}) none of my javascript worked.