- 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 8895 Articles for Front End Technology
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
1K+ Views
To prevent jQuery events from bubbling up to parent elements, use the stopPropogation() method. The stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent handlers from being notified of the event.ExampleYou can try to run the following code to prevent jQuery events from bubbling up to parent elements −Live Demo jQuery stopProagation() method $(document).ready(function() { $("div").click(function(event){ alert("This is : " + $(this).text()); event.stopPropagation(); }); }); div { margin:20px; padding:20px; border:2px solid #666; width:160px; } Click on any box to see the effect: OUTER BOX INNER BOX
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
201 Views
To stop the bubbling of an event to parent elements, use the stopPropagation() method. You can try to run the following code to learn how to stop the bubbling of an event to parent elements −ExampleLive Demo jQuery stopPropagation() method $(document).ready(function() { $("div").click(function(event){ alert("This is : " + $(this).text()); event.stopPropagation(); }); }); div { margin:10px; padding:12px; border:2px solid #666; width:160px; } Click on any box to see the effect: OUTER BOX INNER BOX
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
673 Views
To prevent the browser from executing the default action in jQuery, use the preventDefault() method. The preventDefault() method prevents the browser from executing the default action.ExampleYou can use the method isDefaultPrevented() to know whether this method was ever called (on that event object).Live Demo jQuery preventDefault() method $(document).ready(function() { $("a").click(function(event){ event.preventDefault(); alert( "Default behavior is disabled!" ); }); }); Click the following link and it won't work: GOOGLE Inc.
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
2K+ Views
To get attribute of an element, use the attr() method in jQuery. You can try to run the following code to get attribute of an element using the ‘click’ event −ExampleLive Demo $(document).ready(function(){ $("button").click(function(){ alert("Width of image: " + $("img").attr("width")); }); }); Get Width
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
158 Views
Commonly used event methods include $(document).ready(), click(), dblclick() etc. There is a list of methods which can be called on an Event Object, The following are some of the methods which can be called on an Event Object, S.NoMethod and Description1preventDefault() Prevents the browser from executing the default action.2isDefaultPrevented() Returns whether event.preventDefault() was ever called on this event object.3isPropagationStopped() Returns whether event.stopPropagation() was ever called on this event object.4stopImmediatePropagation() Stops the rest of the handlers from being executed.Let us see an example of stopPropagation() method. The stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent handlers from being notified ... Read More
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
384 Views
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
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
264 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
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
885 Views
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
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
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: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