This should work (from a few alterations to your code above).
function tableCreate() { var body = document.getElementsByTagName('body')[0]; var tbl = document.createElement('table'); tbl.style.width = '100%'; tbl.setAttribute('border', '1'); var tbdy = document.createElement('tbody'); for (var i = 0; i < 3; i++) { var tr = document.createElement('tr'); for (var j = 0; j < 2; j++) { if (i == 2 && j == 1) { break } else { var td = document.createElement('td'); td.appendChild(document.createTextNode('\u0020')) i == 1 && j == 1 ? td.setAttribute('rowSpan', '2') : null; tr.appendChild(td) } } tbdy.appendChild(tr); } tbl.appendChild(tbdy); body.appendChild(tbl) } tableCreate();
Related Posts:
- Add table row in jQuery
- Sorting HTML table with JavaScript
- What is the best way to remove a table row with jQuery?
- getElementsByClassName not working [duplicate]
- Understanding unique keys for array children in React.js
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- Generate random number between two numbers in JavaScript
- Difference between npx and npm?
- How do I copy to the clipboard in JavaScript?
- Array of JSON Objects
- Cannot read property ‘push’ of undefined when combining arrays
- window.onload vs document.onload
- Is there a difference between /\s/g and /\s+/g?
- How to read an external local JSON file in JavaScript?
- How to call an async arrow function with await
- Get the current URL with JavaScript?
- How do I empty an array in JavaScript?
- What’s the difference between event.stopPropagation and event.preventDefault?
- How do I chop/slice/trim off last character in string using Javascript?
- What is causing this error – “Fatal error: Unable to find local grunt”
- Escape quotes in JavaScript
- “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query
- Firebase Permission Denied
- Using Javascript in CSS
- How can I mock an ES6 module import using Jest?
- What is “assert” in JavaScript?
- How does the data-toggle attribute work? (What’s its API?)
- Setting background-image using jQuery CSS property
- What is ESNext?
- SyntaxError: Cannot use import statement outside a module
- Appending to an object
- What is the meaning of “$” sign in JavaScript
- How to determine the installed webpack version
- Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- jQuery disable/enable submit button
- Uncaught Invariant Violation: Too many re-renders. React limits the number of renders to prevent an infinite loop
- node-request – Getting error “SSL23_GET_SERVER_HELLO:unknown protocol”
- Parse an HTML string with JS
- JS file gets a net::ERR_ABORTED 404 (Not Found)
- Shortest way to print current year in a website
- push object into array
- module.exports “Module is not defined”
- Why doesn’t JavaScript support multithreading?
- plain count up timer in javascript
- Uncaught TypeError: Cannot read property ‘name’ of undefined
- How to calculate date difference in JavaScript?
- How to add an object to an array
- Finding the average of an array using JS
- Is it possible to simulate key press events programmatically?
- Vue template or render function not defined yet I am using neither?
- Cannot read property ‘length’ of null (javascript)
- Caesar Cipher in Javascript
- Can’t perform a React state update on an unmounted component
- Return array from function
- Why define an anonymous function and pass it jQuery as the argument?
- Error parsing XHTML: The content of elements must consist of well-formed character data or markup
- How to scroll an HTML page to a given anchor
- Javascript call() & apply() vs bind()?
- “google is not defined” when using Google Maps V3 in Firefox remotely
- How to check if the URL contains a given string?
- Check if url contains string with JQuery
- what is the best way to check variable type in javascript
- JavaScript Array Push key value
- stopPropagation vs. stopImmediatePropagation
- How to replace regular jquery calls with CDN calls from Google?
- Editing Source Code in WordPress
- wp_enqueue_script isn’t connecting my custom js file
- How/Where is editor.min.js Added to the wp-admin Post Page?
- Why is this gutenberg custom format button only available from the toolbar as a dropdown?
- Should a WordPress plugin polyfill the global JS environment?
- Close TinyMCE plugin window on click away
- Running JS after theme customizer finished initialization
- Script Localization doesn’t work
- Help display image in single post using javascript zoom image..?
- How to conditionally show/hide controls & sections in WordPress customizer?
- Uncaught TypeError [closed]
- Checks when fetching data from multiple REST API endpoints in Gutenberg
- How to get the title of the item that is clicked on
- Correct way to include extra styles & script files?
- How can I allow HTML in Gutenberg UI elements help text?
- UnitControl – Block has encountered an error
- Building a Featured Gallery component for Gutenberg
- Should I manually resolve WP Core File security issues or await a subsequent WP release?
- Uncaught TypeError: switchEditors.switchto is not a function
- Check if user can in javascript
- My code will not execute in wordpress, even though I’ve been told the code is fine
- Rest API and how to deal with it in server side
- Is it possible to override only a part of another plugin’s / theme’s js (asset) file?
- Gutenberg – dynamically created element: how to set onChange?
- JSX SVG Icon with WordPress
- How do I integrate a codepen?
- Can I just insert JavaScript by using ?
- Gutenberg Edit Block Inspector Controls and save
- JavaScript and Google PageSpeed + wp_enqueue_script
- Adding javascript blocks to a single file and adding it to the header
- How to modify a class in load-scripts.js ?
- How to integrate a different (JavaScript) editor in WordPress?
- Add Javascript/Html into a WordPress
- Why is this script not working?