- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9321 Articles for Object Oriented Programming
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
2K+ Views
Use the pageBreakInside property in JavaScript to set the page-break behavior inside an element. Use the auto property to insert page break inside an element. Use auto or avoid property value to automatically insert page break inside an element, if needed, or avoid a page break, respectively.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior inside an element with JavaScript − Heading 1 This is demo text. This is demo text. This ... Read More
![Nikitha N](https://www.tutorialspoint.com/assets/profiles/13558/profile/60_76068-1512713229.jpg)
632 Views
Use the pageBreakAfter property in JavaScript to set the page-break behavior after an element. Use the always property for page after an element.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior after an element with JavaScript − Heading 1 This is demo text. This is demo text. This if footer text. Set page-break function display() { document.getElementById("myFooter").style.pageBreakAfter = "always"; }
![Priya Pallavi](https://www.tutorialspoint.com/assets/profiles/13562/profile/60_91320-1512544134.jpg)
51 Views
Use the flexGrow property to set how much the item will grow relative to the rest with JavaScript.ExampleYou can try to run the following code to learn how to work with flexGrow property − #box { border: 1px solid #000000; width: 250px; height: 150px; display: flex; flex-flow: row wrap; } #box div { flex-grow: 0; flex-shrink: 1; flex-basis: 20px; } DIV1 DIV2 DIV3 Using flexGrow property Set function display() { document.getElementById("myID").style.flexGrow = "2"; }
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
146 Views
Use the flexFlow property to set the flexible items to be visible in columns.ExampleYou can try to run the following code to make flexible items display in columns with JavaScript − #box { border: 1px solid #000000; width: 100px; height: 150px; display: flex; flex-flow: row wrap; } #box div { height: 40px; width: 40px; } DIV1 DIV2 DIV3 Using flexDirection property Set function display() { document.getElementById("box").style.flexFlow = "column nowrap"; }
![Abhinaya](https://www.tutorialspoint.com/assets/profiles/13548/profile/60_54851-1512705920.jpg)
70 Views
Use the flex property in JavaScript to set the length of the item relative to the rest. You can try to run the following code to implement flex property with JavaScript −Example #box { border: 1px solid #000000; width: 300px; height: 400px; display: flex; } DIV1 DIV2 DIV3 Set function display() { var a = document.getElementById("box"); var b = a.getElementsByTagName("DIV"); var j ; for (j = 0; j < b.length; j++) { b[j].style.flex = "1"; } }
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
107 Views
Here are some of the best JavaScript compressors available −Google Closure CompilerThe Google Closure compiler runs JavaScript quickly and used for a superior JavaScript. It parses your JavaScript, analyzes it, removes dead code, rewrites, and minimizes what's left.JSMinIf you want to minify, then use the JSMin to remove unnecessary comments.YUI CompressorThe YUI Compressor is used to minify the JavaScript files fastly and is secure.
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
383 Views
The window object includes the location object in JavaScript. It includes the following properties −window.location.hrefIt returns the URL of the current page.Example Click below to get the complete URL of the page. URL function display() { var res = location.href; document.write(res); } window.location.replaceIt is used to replace the current document.Example Replace current document function display() { location.replace("https://www.qries.com") } window.location.assignIf you want to load a new document, use JavaScript assign.Example Open new document function display() { location.assign("https://www.qries.com") }
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
96 Views
Use the removeEventListener() method in JavaScript to remove event handler attached with addEventListener() method.Example #box { background-color: gray; border: 2px dashed; } Demo Text! Click below to remove event handler. Remove document.getElementById("box").addEventListener("mousemove", display); function display() { document.getElementById("pid").innerHTML = Math.random(); } function removeEvent() { document.getElementById("box").removeEventListener("mousemove", display); }
![Saurabh Jaiswal](https://www.tutorialspoint.com/assets/profiles/500262/profile/60_1406912-1660202490.jpg)
1K+ Views
This tutorial will teach how to add an event handler to an element in JavaScript. There are two ways to add an event handler to any element, the first is using the addEventListener method and another is using the event attributes. Using the addEventListener() Method The addEventListener() method is used to attach an event handler to any DOM element. The syntax of this method is following. Syntax element.addEventListener( event, function, capture ) Parameter Event − The name of the event you want to apply on the element e.g. click, mouseover, submit, etc. Function − The callback function which ... Read More
![Saurabh Jaiswal](https://www.tutorialspoint.com/assets/profiles/500262/profile/60_1406912-1660202490.jpg)
10K+ Views
It is very common to use the events while we are programming in JavaScript. Suppose you are creating a modal that opens up on clicking a button or hovering over using the cursor, here we using two events on a single element but JavaScript does not have any official way to use many event listeners on a single element. In this article, we will learn How to add many Event Handlers to the same element with JavaScript HTML DOM. To achieve this, we have the following approaches given below. Using Multiple addEventListener Methods Using the ES6 Way Using ... Read More