- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 7800 Articles for Front End Technology

Updated on 11-Dec-2019 07:39:51
To work with jQuery Datepicker onchange(), use the datepicker onSelect event. This will show which date we added currently and changed to.ExampleYou can try to run the following code to learn how to work jQuery Datepicker onchange:Live Demo
$( function() {
$(".date").datepicker({
onSelect: function(dateText) {
display("Selected date: " + dateText + ", Current Selected Value= " + this.value);
$(this).change();
}
}).on("change", function() {
display("Change event");
});
function display(msg) {
$("").html(msg).appendTo(document.body);
}
});
Date:

Updated on 11-Dec-2019 07:57:32
Events are actions that can be detected by your Web Application. When these events are triggered you can then use a custom function to do pretty much whatever you want with the event. These custom functions call Event Handlers.ExampleLet us see an example of bind() jQuery event. Using the jQuery Event Model, we can establish event handlers on DOM elements with the bind() method as follows:Live Demo jQuery bind() $(document).ready(function() { $('div').bind('click', ... Read More 
Updated on 11-Dec-2019 07:44:05
To handle HTML5 media events using jQuery, use the click() method.ExampleYou can try to run the following code to learn how to handle HTML5 media events such as playing a song:Live Demo
$(document).ready(function(){
var x = $(".myPlayer").length; // Count total audio players
var z = 0; // Start at first audio player
$("#play-bt").click(function(){
$(".myPlayer")[z].play();
$(".message").text("Music started");
})
$("#stop-bt").click(function(){
$(".myPlayer")[z].pause();
$(".myPlayer")[z].currentTime = 0;
$(".message").text("Music Stopped");
})
});
Play music
Stop music

Updated on 14-Feb-2020 12:44:34
The event.namespace property is used to return the custom namespace when the event was triggered.ExampleYou can try to run the following code to learn how event namespace works and how to create and remove namespace −Live Demo
$(document).ready(function(){
$("p").on("custom.myNamespace",function(event){
alert(event.namespace);
});
$("p").click(function(event){
$(this).trigger("custom.myNamespace");
});
$("button").click(function(){
$("p").off("custom.myNamespace");
});
});
Click me
Click above to generate an alert box. Click the below button to remove namespace, which won’t generate an alert box.
Click this button to remove namespace.

Updated on 14-Feb-2020 12:43:26
The jQuery event for user pressing enter is keyup and keyCode. You can try to run the following code to trigger an event on pressing enter key in textbox,ExampleLive Demo
$(document).ready(function(){
$('input').bind("enterKey",function(e){
alert("Enter key pressed");
});
$('input').keyup(function(e){
if(e.keyCode == 13)
{
$(this).trigger("enterKey");
}
});
});
Press Enter key in the above input text.

Updated on 14-Feb-2020 12:42:28
jQuery also provides a set of event helper method which can be used either to trigger an event to bind any event types mentioned above.Trigger MethodsThe following is an example which would triggers the blur event on all paragraphs −$("p").blur();Binding MethodsThe following is an example which would bind a click event on all the −$("div").click( function () { // do something here });Here are some of the jQuery Event Helper methods:S. NoMethod & Description1.blur()Triggers the blur event of each matched element.2.blur( fn )Bind a function to the blur event of each matched element.3.click( )Triggers the click event of ... Read More 
Updated on 14-Feb-2020 12:40:26
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 −Live Demo $(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 
Updated on 14-Feb-2020 12:35:23
Use the jQuery on() method to bind jQuery events on elements generated through other events. You can try to run the following code to learn how to use on() method to bind jQuery events:ExampleLive Demo
$(document).ready(function(){
$(document).on({
mouseenter: function (e) {
alert('mouse enter');
},
mouseleave: function (e) {
alert('mouse leave');
}
}, '.demo');
});
Heading 1
Demo One
Demo Two
Mouse enter and leave will generate alert boxes.

Updated on 14-Feb-2020 12:34:23
To suppress jQuery event handling temporarily, add a class to your element so that you can prevent further code from execution.ExampleYou can try to run the following code to learn how to suppress jQuery event handling −Live Demo
$(document).ready(function(){
$(element).click(function(e) {
e.preventDefault();
// Check for fired class
if ($(this).hasClass('fired') == false) {
// Add fired class
$(element).addClass('fired');
// Remove fired class
$(element).removeClass('fired');
}
});
});
.fired {
font-size: 25px;
color: green;
}
This is a heading
This is a paragraph.
This is second paragraph.

Updated on 14-Feb-2020 12:33:20
Use the off() method to override jQuery event handlers. This method is used to remove an event handler. The on() method is used to attach one or more event handler.ExampleYou can try to run the following code to learn how to override jQuery event handlers −Live Demo
jQuery off() method
$(document).ready(function() {
function aClick() {
$("div").show().fadeOut("slow");
}
$("#bind").click(function () {
$("#theone").on("click", aClick).text("Can Click!");
});
$("#unbind").click(function () {
$("#theone").off("click", aClick).text("Does nothing...");
});
});
button {
margin:5px;
}
button#theone {
color:red;
background:yellow;
}
Does nothing...
Bind Click
Unbind Click
Click!
Advertisements