Found 8895 Articles for Front End Technology

How to disable resizable property of textarea using JavaScript?

Rahul Sharma
Updated on 13-Jun-2020 06:39:07

155 Views

To disable resizable property, use CSS style −textarea {    resize: none; }To disable specific textarea with different attribute values, try the following. Let’s say the attribute is set to “demo” −textarea[name=demo] {    resize: none; }Let’s say the id attribute is “demo” −For the above,#demo {    resize: none; }

How to handle when JavaScript is turned off?

Johar Ali
Updated on 13-Jun-2020 06:37:30

78 Views

Nowadays, almost every web browser supports JavaScript. If it is turned off, you can use tag. To let users know about non-JavaScript web browsers, use the tag. The HTML tag is used to handle the browsers, which do recognize tag but do not support scripting. This tag is used to display an alternate text message.Example           HTML noscript Tag                                              Your browser does not support JavaScript!          

JavaScript function in href vs. onClick

Amit Sharma
Updated on 24-Jun-2024 15:36:43

10K+ Views

Both onclick & href have different behaviors when calling JavaScript directly. Also the script in href won’t get executed if the time difference is short. This is for the time between two clicks.ExampleHere’s an example showing the usage of href vs onClick in JavaScript. Live Demo           JavaScript href vs onClick()              function myFunc() {          var v = 0;          for (var j=0; j

What is the difference between global and local Variables in JavaScript?

Swarali Sree
Updated on 15-Jun-2020 12:06:30

5K+ Views

The scope of a variable is the region of your program in which it is defined. JavaScript variables have only two scopes.Global Variables − A global variable has a global scope which means it can be defined anywhere in your JavaScript code.Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a global ... Read More

How to declare variables in JavaScript?

Rahul Sharma
Updated on 13-Jun-2020 06:32:51

885 Views

Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.Before you use a variable in a JavaScript program, you must declare it. Variables are declared with the var keyword as follows.     You can also declare multiple variables with the same var keyword as follows −     Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or at a later point in ... Read More

What is the difference between window.onload and document.onload in Javascript?

Samual Sam
Updated on 15-Jun-2020 12:05:46

1K+ Views

document.onloadIt gets fired prior to loading of images and other external content. document.onload event is fired before the window.onload.window.onloadIt gets fired when the complete page loads, which includes images, scripts, css, etc.ExampleHere’a an example to understand onload.Live Demo           JavaScript Animation                                                        Click button below to move the image to right                    

How to place JavaScript in External Files?

Amit Sharma
Updated on 13-Jun-2020 06:21:49

238 Views

To place JavaScript in external file create an external JavaScript file with the extension .js. After creating, add it to the HTML file in the script tag. The src attribute is used to include that external JavaScript file.If you have more than one external JavaScript file, then add it to the same web page to increase the performance of the page.Let’s say the following new.js is our external JavaScript file −function display() {    alert("Hello World!"); }Now add the external JavaScript file to the HTML web page −                                      

When should I use an Inline script and when to use external JavaScript file?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

1K+ Views

To enhance performance, try to keep JavaScript external. The separate code makes it easier for web browsers to cache. However, use inline scripts only when you’re making single page websites. Still, it's better to use external code i.e. external JavaScript. To place JavaScript in external file create an external JavaScript file with the extension .js. After creating, add it to the HTML file in the script tag. The src attribute is used to include that external JavaScript file. If you have more than one external JavaScript file, then add it to the same web page to increase the performance of ... Read More

How do I put a jQuery code in an external .js file?

Ali
Ali
Updated on 20-Feb-2020 05:23:20

6K+ Views

Create an external JavaScript file and add the jQuery code in it.ExampleLet’s say the name of the external file is demo.js. To add it in the HTML page, include it like the following −                               Hello     Above we added jQuery using Google CDN and the external file was included after that.Add jQuery code in demo.js, since you wanted to place jQuery code −$(document).ready(function(){    alert(“amit”) });

What is the difference between anonymous and inline functions in JavaScript?

Rahul Sharma
Updated on 13-Jun-2020 06:18:52

2K+ Views

Anonymous FunctionsAnonymous, as the name suggests, allows creating a function without any names identifier. It can be used as an argument to other functions. This is how JavaScript anonymous functions can be used −var myfunc = function() {    alert(‘This is anonymous'); }Another example can be the following −setTimeout(function() {    alert('Demo'); }, 3000);Inline FunctionsAn inline function is a javascript function, which is assigned to a variable created at runtime. You can difference Inline Functions easily with Anonymous since an inline function is assigned to a variable and can be easily reused.This is how JavaScript inline functions can be used −var ... Read More

Advertisements