Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- </head>
- <body>
- <div id="output"></div>
- <script type="text/javascript">
- var functionCreate = function(intWidth, intHeight) {
- $('<table></table>').attr('border', '1');
- $('<table></table>').append('<tr></tr');
- //$.each(intHeight, function(intHeight, r) {
- // var row = $('<tr></tr>');
- // $.each(intHeight, function(intHeight, r) {
- //});
- //});
- //var data = $('<td></td>');
- // create a table with the width and height and in doing so, set the text to each cell / td element to 'y.x' (see example below)
- // remember that you were already asked to create a table in the javascript section, but here you are asked to return a jquery object that represents a table
- // to do this, you will have create jquery elements that represent the tr / td elements and append them systematically to a jquery table element
- return jQuery('<table></table>');
- };
- jQuery('#output')
- .append(functionCreate(3, 2))
- ;
- // expected table for functionCreate(2, 1):
- // <table border="1">
- // <tr>
- // <td>1.1</td>
- // <td>1.2</td>
- // </tr>
- // </table>
- // expected table for functionCreate(3, 2):
- // <table border="1">
- // <tr>
- // <td>1.1</td>
- // <td>1.2</td>
- // <td>1.3</td>
- // </tr>
- // <tr>
- // <td>2.1</td>
- // <td>2.2</td>
- // <td>2.3</td>
- // </tr>
- // </table>
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement