Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

document on click not working

$(document).ready(function() {
    // This WILL work because we are listening on the 'document', 
    // for a click on an element with an ID of #test-element
    $(document).on("click","#test-element",function() {
        alert("click bound to document listening for #test-element");
    });

    // This will NOT work because there is no '#test-element' ... yet
    $("#test-element").on("click",function() {
        alert("click bound directly to #test-element");
    });

    // Create the dynamic element '#test-element'
    $('body').append('<div id="test-element">Click mee</div>');
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: js every 
Javascript :: jquery if element appears 
Javascript :: Missing script: "start" react 
Javascript :: react hide element 
Javascript :: capitalize first letter of each word 
Javascript :: window resize done 
Javascript :: encrypt in js 
Javascript :: windows scroll condition 
Javascript :: background image not loading from a link react 
Javascript :: javascript comparison operators 
Javascript :: handle onchange react 
Javascript :: js event on change focus 
Javascript :: split string to char js 
Javascript :: jason in javascript 
Javascript :: why can i put comments in some json files 
Javascript :: js basic user class 
Javascript :: classic asp get json from url 
Javascript :: angularjs 1.5.6 cdn 
Javascript :: next js styled components classname did not match 
Javascript :: Capturing enter in javascript 
Javascript :: How to find unique values from an array in sorted order js 
Javascript :: jquery plugin for searchable dropdown 
Javascript :: jspdf 
Javascript :: dynamic button click in javascript 
Javascript :: discord.js random output 
Javascript :: Uncaught (in promise) DOMException: Failed to load because no supported source was found. 
Javascript :: funciones invocan a funciones javascript 
Javascript :: command to start a new react app using vite 
Javascript :: Check for mobile device 
Javascript :: npm get package.json version 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =