Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen text area without JQuery

Tags:

javascript

How to make fullscreen textarea without Jquery or any library?

let el = document.getElementById('#t')

const fullScrenn = () => {
	  //there way to do that . 
}
 
<textarea id="el" cols="30" rows="10"></textarea>

<button onclick="fullScrenn()">Full Screen</button>

enter image description here

like image 843
Sebastian Lagua Avatar asked Jun 02 '17 09:06

Sebastian Lagua


People also ask

How do I increase the width of a textarea in HTML?

The cols attribute specifies the visible width of a text area. Tip: The size of a text area can also be set by the CSS height and width properties.

How do I force HTML full screen?

Full-screen can be activated for the whole browser window by pressing the F11 key. It can be exited by pressing the Esc button.

How do you get the full width of a text area?

Inside that <div> element, we create a text area with a certain number of columns and rows. In this case, it is 30 and 15 respectively. After that, we set the width property to 100% to make a textarea width 100%. HTML Code: The HTML code contains a <textarea> element that holds rows and columns values.

How do I fix the text area size?

We can set the size for the text area by using rows and columns. rows*columns will be the size of the text area. For columns, we have to use the cols keyword.


1 Answers

'use strict';
document.querySelector('#myButton').addEventListener('click', () => {
  document.querySelector('#myTextarea').style.width="100vw";
  document.querySelector('#myTextarea').style.height="100vh";
});
<textarea id="myTextarea" cols="20" rows="20"></textarea>
<button id="myButton">Full Size</button>

Just set the width and height of the textarea to 100vw (the width of the screen) and 100vh (the height of the screen).

Alternatively you could use window.innerWidth and window.innerHeight instead of those values.

like image 96
Merunas Grincalaitis Avatar answered Oct 07 '22 12:10

Merunas Grincalaitis