How to display alt tag on image as text using jQuery

Have you ever had an image that you wanted to let a user click and display text? For example; Show hidden price? Hidden image/text game? Although most browsers support hover over the img element to display the "title", this does not work in most mobile browsers. Android allows tap and hold on the image to display the title, but iPhone does not. I've got an alternative solution. See below:

      alt="my alt" 
      title="my title">
    <div id="show-text"></div>
      $("img").on("click", function() {
        if( !$.trim( $('#show-text').html() ).length ) {
        } else {

See an example in action at jsFiddle


Popular posts from this blog

Download Artifacts from Jenkins with WGET

How to set Etrade default Home Page