Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to use text onclick to display images in javascript

$('img').click(function () { // on a click
  if($(this).attr('id') == '1') { // get the id attribute
    $('#div').html('Image with 1 was clicked'); // write the text
  } else { // else if
     // write something else for the 2
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js hex encode 
Javascript :: what is closure in javascript 
Javascript :: javascript async await not waiting 
Javascript :: nuxt custom plugin 
Javascript :: javascript detect back space 
Javascript :: mock createRef jest react functional component 
Javascript :: json type error at login 
Javascript :: check if date is less than today moment 
Javascript :: add kendo ui dropdown to angular 
Javascript :: monaco editor no numbers 
Javascript :: react extends component Increment data 
Javascript :: switch variables javascript 
Javascript :: multiselect_3 
Javascript :: get character length javascript 
Javascript :: how to transform object in string with scaped 
Javascript :: jsconfig.json code to support absolute import 
Javascript :: react spinner 
Javascript :: async function javascript dec 
Javascript :: javascript desktop app 
Javascript :: tinymce editor description value is not getting onclick js 
Javascript :: alpinjs 
Javascript :: javascript delete dict value 
Javascript :: how to hide api key in react app 
Javascript :: javascript scale values 
Javascript :: $("#id").submit in vanilla 
Javascript :: chart js react 
Javascript :: stimulus params 
Javascript :: player.filter 
Javascript :: how to mouse hover svg 
Javascript :: dividing a number into digits javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =