Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

on() jquery

$('button').on('click', function() {
  alert('button was clicked!');
});
Comment

jquery on method

 //more flexible way of adding an event listener;
 //using the .on method
$('h1').on('mouseover', function(){
    $('h1').css('color', '#'+Math.floor(Math.random()*16777215).toString(16));
})//the above changes your h1 elements color property to a random color
//but other events can be used as well. see source and below
//Guess what this does
$(document).on('keypress', function(event){
    if (event.key === 'a') {
        console.log('move left function...');
        $('h1').css('color', '#'+Math.floor(Math.random()*16777215).toString(16));
      }     
})

//Answer Below





//everytime you press 'a' the text in your h1 becomes a different color
Comment

on() jquery

function notify () {
  alert("clicked" );
}
$("button").on("click", notify );
Comment

/on in jquery


$('.elementClass').click(function() { // code 
});

Comment

PREVIOUS NEXT
Code Example
Javascript :: offsetheight javascript 
Javascript :: javascript join object properties in array 
Javascript :: jquery form serialize object 
Javascript :: discord.js how to send message 
Javascript :: Map in Javascript in LWC 
Javascript :: npx http server 
Javascript :: findbyid mongoose 
Javascript :: set attribute using each jquery 
Javascript :: new date parameters javascript 
Javascript :: javascript option yes/no popup 
Javascript :: react antd form disable submit button 
Javascript :: jquery next sibling with class 
Javascript :: angularjs date filter 
Javascript :: date now js 
Javascript :: continuous scrolling js 
Javascript :: reverse every word in a string javascript 
Javascript :: how to delete cookie node js 
Javascript :: execute a function at a certain time of day js 
Javascript :: jq each loop 
Javascript :: pass params axios get react 
Javascript :: react bootstrap add progress bar 
Javascript :: sequelize desc does not exist 
Javascript :: react router get data from url 
Javascript :: how to round numbers in javscript 
Javascript :: foreach break js 
Javascript :: jquery chek radio 
Javascript :: select in react js 
Javascript :: react append classname 
Javascript :: generate an array of random numbers javascript 
Javascript :: javascript currency format 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =