Articles on Trending Technologies

Technical articles with clear explanations and examples

How to wrap and unwrap HTML control with a div dynamically using jQuery?

Amit D
Amit D
Updated on 11-Mar-2026 598 Views

To wrap html control, use the wrap() method and unwrap() method to unwrap html control.ExampleYou can try to run the following code to wrap and unwrap html control with a div dynamically using jQuery. $(document).ready(function(){     $("#button1").click(function(){        $("p").wrap("");     });     $("#button2").click(function(){        $("p").unwrap();     }); });   div {      background-color: gray;   } This is demo text. This is another text. Wrap Unwrap

Read More

How to Scroll to the top of the page using JavaScript/ jQuery?

Anjana
Anjana
Updated on 11-Mar-2026 307 Views

Example                    $("a").click(function() {             $("html, body").animate({ scrollTop: 0 }, "slow");             return false;          });             TOP OF PAGE             This is demo text.       This is demo text.       This is demo text.       This is demo text.       This is demo text.       This is demo text.       This is demo ...

Read More

How to turn a String into a JavaScript function call?

Smita Kapse
Smita Kapse
Updated on 11-Mar-2026 567 Views

To turn a string into a JavaScript function call, try to run the following codeExample                    function myFunction(argument) {             alert('My function ' + argument);          }          functionName = 'myFunction';          window[functionName]('is working.');          

Read More

How to use variable number of arguments to function in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 11-Mar-2026 696 Views

To use a variable number of arguments to function, use the arguments object.ExampleYou can try to run the following code to implement arguments to a function in JavaScript                    function functionArgument(val1, val2, val3)  {             var res = "";             res += "Expected Arguments: " + functionArgument.length;             res += "";             res += "Current Arguments : " + arguments.length;             res += "";             res += "Each argument = "             for (p = 0; p < arguments.length; p++) {                res += "";                res += functionArgument.arguments[p];                res += " ";             }             document.write(res);          }          functionArgument(20, 50, 80, "Demo Text!","Hello World", new Date())          

Read More

How to get objects by ID, Class, Tag, and Attribute in jQuery?

Amit D
Amit D
Updated on 11-Mar-2026 1K+ Views

Here’s how you can get objects by ID Selector (#id), by Class Selector (.class), by Tag, and Attribute (.attr()).Get Object by Class SelectorExampleThe element class selector selects all the elements which match with the given class of the elements.           jQuery Selector                          $(document).ready(function() {                 $(".big").css("background-color", "yellow");          });                                  This is first division ...

Read More

How can I bind all events on a DOM element using jQuery?

Ricky Barnes
Ricky Barnes
Updated on 11-Mar-2026 759 Views

The bind( type, [data], fn ) method binds a handler to one or more events (like click) for each matched element. It can also bind custom events.Possible event values − blur, focus, load, resize, scroll, unload, click etc.Here is the description of all the parameters used by this method −type − One or more event types separated by a space.data − This is optional parameter and represents additional data passed to the event handler as event.data.fn − A function to bind to the event on each of the set of matched elements.ExampleYou can try to run the following code to learn how to ...

Read More

What is &quot;function*&quot; in JavaScript?

Smita Kapse
Smita Kapse
Updated on 11-Mar-2026 336 Views

The function* declaration is used to define a generator function. It returns a Generator object. Generator Functions allows execution of code in between when a function is exited and resumed later. So, generators can be used to manage flow control in a code.SyntaxHere’s the syntax −function *myFunction() {} // or function* myFunction() {} // or function*myFunction() {}Let’s see how to use generator functionExample                    function* display() {             var num = 1;             while (num < 5)             yield num++;          }          var myGenerator = display();          document.write(myGenerator.next().value);          document.write(""+myGenerator.next().value);          document.write(""+myGenerator.next().value);          document.write(""+myGenerator.next().value);          document.write(""+myGenerator.next().value);          

Read More

How to check the element type of an event target with jQuery?

Ricky Barnes
Ricky Barnes
Updated on 11-Mar-2026 2K+ Views

To check the element type pf an event target, using the is() method.ExampleYou can try to run the following code to check the element type: $(document).ready(function(){    $( "ul" ).click(function( event ) {       var target = $( event.target );       if ( target.is( "li" ) ) {          alert("Element is 'li'")       }   }); }); Click below to find out which element India US UK

Read More

What is the use of JavaScript eval function?

Vrundesha Joshi
Vrundesha Joshi
Updated on 11-Mar-2026 399 Views

The JavaScript eval() is used to execute an argument. The code gets execute slower when the eval() method is used. It also has security implementations since it has a different scope of execution. In addition, use it to evaluate a string as a JavaScript expression.The eval() method is not suggested to use in JavaScript since it executes slower and improper usage opens your website to injection attacks.ExampleHere’s how you can implement eval() function                    var a = 30;          var b = 12;          var res1 = eval("a * b") + "";          var res2 = eval("5 + 10") + "";          document.write(res1);          document.write(res2);          

Read More

What is an Event Object in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 11-Mar-2026 508 Views

The callback function takes a single parameter; when the handler is called the JavaScript event object will be passed through it.The event object is often unnecessary and the parameter is omitted, as sufficient context is usually available when the handler is bound to know exactly what needs to be done when the handler is triggered, however there are certain attributes which you would need to be accessed.Let us see an example of isDefaultPrevented() method. The isDefaultPrevented() method checks whether event.preventDefault() was ever called on this event object.ExampleYou can try to run the following code to learn how to work with ...

Read More
Showing 381–390 of 61,248 articles
« Prev 1 37 38 39 40 41 6125 Next »
Advertisements