Articles on Trending Technologies

Technical articles with clear explanations and examples

How can I pass a parameter to a setTimeout() callback?

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 2K+ Views

To pass a parameter to setTimeout() callback, use the following syntax −setTimeout(functionname, milliseconds, arg1, arg2, arg3...)The following are the parameters −function name − The function name for the function to be executed.milliseconds − The number of milliseconds.arg1, arg2, arg3 − These are the arguments passed to the function.ExampleYou can try to run the following code to pass a parameter to a setTimeout() callback           Submit                function timeFunction() {             setTimeout(function(){ alert("After 5 seconds!"); }, 5000);          }          Click the above button and wait for 5 seconds.    

Read More

How to fire jQuery events with setTimeout?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 1K+ Views

The jQuery setTimeout() method is used to set an interval for events to fire.ExampleHere, we will set an interval of 3 seconds for an alert box to load using jQuery events: $(document).ready(function(){     $("#button1").click(function(){        setTimeout("alert('Hello World!');", 3000);     }); }); Click Click the above button and wait for 3 seconds. An alert box will generate after 3 seconds.

Read More

How we can prioritize jQuery events?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 1K+ Views

To prioritize jQuery events, use the event.stopPropagation().ExampleYou can try to run the following code to learn how to prioritize using stopPropogation() method: $(document).ready(function(){        var timer;    function out(s) {       if (timer) {         clearTimeout(timer);         timer = null;       }       $("#demo").append(s + "");       timer = setTimeout(function() {         $("#demo").append("-------" + "");         timer = null;       }, 100);    }    $(".li").find('input').click(function(e){     out('li>input');     if ($(this).parent().hasClass("stop")) {         e.stopPropagation();     }    });    $(".li").click(function(e){     out('li');    });    $('input').click(function(e){     out('input');     if ($(this).parent().hasClass("stop")) {         e.stopPropagation();     }    }); }); Demo Demo using stop propagation method

Read More

How to set text font family in HTML?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 28K+ Views

To change the text font family in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML tag, with the CSS property font-family. HTML5 do not support the tag, so the CSS style is used to add font size.Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML tag or external style sheet.ExampleYou can try to run the following code to change the text font family in an HTML page   ...

Read More

Which jQuery events do not bubble?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 187 Views

Some of the jQuery events, do not bubble such as mouseenter do not bubble. Let us see an example of such events.ExampleYou can try to run the following code to learn how to work with jQuery events, which do not bubble,  $(document).ready(function(){     $("p").mouseenter(function(){       $("p").css("background-color", "red");     });     $("p").mouseleave(function(){       $("p").css("background-color", "blue");     });  }); Demo Text - Keep the mouse pointer here.

Read More

How to store and reproduce jQuery events?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 234 Views

To store and reproduce jQuery events, use console to log.ExampleYou can try to run the following code to learn how to store and reproduce jQuery events: $(document).ready(function(){     window.events = []     $("#track").click(function(event){        window.events.push(event)            $.each(window.events, function(i, item){           console.log(i, item);        });    }); }); Track

Read More

How to implement custom events in jQuery?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 1K+ Views

Custom event means you can create your own events in jQuery. For example, create a custom event to fire an alert box on pressing any key on the keyboard.ExampleYou can try to run the following code to learn how to create a custom event, $(document).ready(function(){    $('textarea').bind("enterKey",function(e){      alert("You have pressed Enter key!");    });    $('textarea').keyup(function(e){      if(e.keyCode == 13)      {         $(this).trigger("enterKey");      }    }); });  

Read More

What is the sequence of jQuery events triggered?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 1K+ Views

The jQuery event handlers always execute in the order they were bound. With jQuery, you can also change the sequence. Let’s see how, for example, fromdemo(1); demo(2);We can change the sequence to −demo(2); demo(1);ExampleYou can try to run the following to learn and change the sequence of jQuery events − $(document).ready(function(){     $.fn.bindFirst = function(name, fn) {         this.on(name, fn);         this.each(function() {             var handlers = $._data(this, 'events')[name.split('.')[0]];             var handler = handlers.pop();         ...

Read More

How to add a number of months to a date using JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 809 Views

To add a number of months to a date, first get the month using getMonth() method and add a number of months.ExampleYou can try to run the following code to add a number of months                    var d, e;          d = new Date();          document.write(d);          e = d.getMonth()+1;          document.write("Incremented month = "+e);          

Read More

How to Convert a Java 8 Stream to an Array?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 508 Views

To convert a stream to an Array in Java -Collect the stream to a list using the Collect interface and the Collectors class.Now convert the list to an array using the toArray() method.Exampleimport java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public class J8StreamToArray {    public static void main(String args[]) {       String[] myArray = { "JavaFX", "OpenCV", "WebGL", "HBase" };       Stream stream = Stream.of(myArray);       List list = stream.collect(Collectors.toList());       String[] str = list.toArray(new String[0]);       System.out.println(Arrays.toString(str));    } }Output[JavaFX, OpenCV, WebGL, HBase]

Read More
Showing 401–410 of 61,248 articles
« Prev 1 39 40 41 42 43 6125 Next »
Advertisements