javascript - Making grids using JS or JQuery -
i'm new js , have been working through lessons via odin project. i'm on first js/jquery project , i'm having trouble project:
how use js/jquery user input number between 1-16 , grid pop out size of page. i.e. user types in 3 , 3x3 grid size of webpage comes out? or user types in 16 , 16x16 grid comes out?
i prefer not straight out answer, maybe if point me in right direction starter code? i'm guessing best approach create div , use .append() function? need little more direction here.
here cryptic response require. i've included fill-in-the-blanks , left out how expand table fill screen. hint: use $(window).height()/$(window).width() size of screen.
$('#grid').change(function(){ $('table').remove(); var code = "<table>"; (var = 0; < $('#grid').val(); i++) { code += "???"; (var j = 0; j < $('#grid').val(); j++) { code += "???"; } code += "???"; } code += "</table>"; $('#container').append(code); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="container"> <label>grid size</label> <input type="number" id="grid" /> </div>
Comments
Post a Comment