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

PREVIOUS NEXT
Code Example
Javascript :: javascript subtract years from date 
Javascript :: setstate react 
Javascript :: javascript redirect to file 
Javascript :: how to include a toasted property in vue 
Javascript :: upload image in firebase storage react web 
Javascript :: linux command to install standard js 
Javascript :: replit node version 
Javascript :: how to find dates in a string in js 
Javascript :: python json nested dictionaries 
Javascript :: javascript append list to list 
Javascript :: import file in chrome extension 
Javascript :: lexical scoping in javascript 
Javascript :: map within a map javascript 
Javascript :: pie chart in javascript 
Javascript :: chunking array javascript 
Javascript :: material ui navbar 
Javascript :: js reverse 
Javascript :: use localstorage react hook 
Javascript :: vue state 
Javascript :: Add Text Inside Of React Component 
Javascript :: data-toggle="tooltip not working due to jquery-ui.min.js 
Javascript :: how to call mixin in vuex 
Javascript :: variables in js class 
Javascript :: array.length in mongoose query 
Javascript :: node http request 
Javascript :: native module rnc_asyncsqlitedbstorage tried to override asyncstorage module 
Javascript :: in compare method why we taking a and b for sorting in javascript 
Javascript :: common javascript coding interview questions 
Javascript :: Find index using arrow function 
Javascript :: json concat 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =