Found 7790 Articles for Front End Technology

What are event attributes in jQuery?

Ricky Barnes
Updated on 11-Dec-2019 06:21:12
jQuery events have attributes such as for keyup and keydown events, if the Ctrl key was pressed, timestamp when the event created, etc.The following are some of the event properties/attributes available:S.NoProperty & Description1altKeySet to true if the Alt key was pressed when the event was triggered, false if not. The Alt key is labeled Option on most Mac keyboards.2ctrlKeySet to true if the Ctrl key was pressed when the event was triggered, false if not.3dataThe value, if any, passed as the second parameter to the bind() command when the handler was established.4pageXFor mouse events, specifies the horizontal coordinate of the ... Read More

What is an Event Object in jQuery?

Ricky Barnes
Updated on 11-Dec-2019 06:32:29
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

How to remove event handlers using jQuery?

Ricky Barnes
Updated on 14-Feb-2020 10:37:08
Once an event handler is established, it remains in effect for the remainder of the life of the page. There may be a need when you would like to remove event handler.jQuery provides the unbind() command to remove an exiting event handler. The syntax of unbind() is as follows.The following is the description of the parameters −eventType − A string containing a JavaScript event type, such as click or submit. Refer to the next section for a complete list of event types.handler − If provided, identifies the specific listener that's to be removed.ExampleYou can try to run the following code to learn ... Read More

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

Ricky Barnes
Updated on 11-Dec-2019 06:02:58
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:Live Demo $(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

How to handle bind an event using JavaScript?

Shubham Vora
Updated on 26-Aug-2022 13:35:20
In this tutorial, we will learn how to handle bind an event using JavaScript. Events are the actions or occurrences in the system by the browser or users. There are various types of events that represent various activities performed by the browser or users. For example, if a user clicks on a button, it triggers an event named "click." Similarly, if a webpage finished loading, it triggered an event called "load." An Event Listener is a program that continuously listens to or waits for an event to occur. It is one of the most important parts of JavaScript. The ... Read More

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

Ricky Barnes
Updated on 11-Dec-2019 06:04:49
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

How to handle a mouse right click event using jQuery?

David Meador
Updated on 14-Feb-2020 10:28:21
To handle a mouse right click event, use the mousedown() jQuery method. Mouse left, right and middle click can also be captured using the same method. You can try to run the following code to learn how to handle a mouse right click event:ExampleLive Demo $(document).ready(function(){    $('.myclass').mousedown(function(event) {     switch (event.which) {         case 1:             alert('Left mouse button is pressed');             break;         case 2:             alert('Middle mouse button is pressed');             break;         case 3:             alert('Right mouse button is pressed');             break;         default:             alert('Nothing');     } }); }); Click me

How to handle a double click event using jQuery?

David Meador
Updated on 14-Feb-2020 10:27:25
To handle a double click event using jQuery, use the dblclick() event. When an element is double clicked, this event occurs.ExampleYou can try to run the following code to learn how to handle double click event using jQuery −Live Demo $(document).ready(function(){    $("p").dblclick(function(){      alert("You have clicked this twice.");    }); }); Double click

How to handle a link click event using jQuery?

David Meador
Updated on 14-Feb-2020 10:25:09
To handle a click event using jQuery, use the click() method. You can try to run the following code to handle a link click event using jQuery −ExampleLive Demo  $(document).ready(function(){     $("a").click(function(){         alert("You've clicked the link.");     });  }); Click below link. Click

How can I remove everything inside of a

David Meador
Updated on 14-Feb-2020 10:16:23
To remove everything inside a div element, use the remove() method. You can try to run the following code to remove everything inside a element −ExampleLive Demo $(document).ready(function(){     $(".btn").click(function(){         $("div#demo").remove();     });         }); Hide the elements inside div Inside div- This is demo text. Inside div- This is demo text. Inside span- This is demo text. Inside span- This is demo text.
Advertisements