Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7734405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:14:28+00:00 2026-06-01T07:14:28+00:00

I am trying to dynamically append some objects to a div and then programatically

  • 0

I am trying to dynamically append some objects to a div and then programatically trigger a click event of the first image when they have all been created. The following code works and does this successfully in Firefox on a PC but when I test it on an iPhone I get the following error in the developer window –

TypeError:Result of expression ‘document.getElementById(“image0”).click [undefined] is not a function

Here is my code –

function processData(data) {        
$.each(data, function(i) {               
    $('<div>').append($('<img>').attr('src', '').attr('id','image'+i)).data('large', this[0]).appendTo('#gallery');
});
$('#gallery div').touchGallery({
    getSource: function() {
    var f = $(this).data('large');
    return f;
}
});
document.getElementById("image0").addEventListener('click', function(){},false);    
document.getElementById("image0").click();  
}

Like I say this works fine with Firefox. I am guessing that perhaps there is a different way to trigger click events on touch devices? Or is this event possible? I am using TouchGallery to display a slideshow of images and instead of showing the gallery of images and requiring users to click to start the slideshow I would like to automatically start it.

Any leads?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:14:30+00:00Added an answer on June 1, 2026 at 7:14 am

    Why aren’t you using jQuery for the click-event-binding?

    I think the error is that javascript doesn’t know the .click() you are using (even though firefox apparantly does support this).

    $("#image0").click(function(){}); should do the trick.

    (Or, since you are adding images in the gallery div after the DOM’s loaded: use $("#gallery").delegate("img", "click", function(event){});)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i'm trying to dynamically append some divs and then use jquery on them
I am trying to dynamically append where conditions into a single expression-object, then pass
I'm trying to dynamically and a link to an image, however I cannot correctly
I am trying to dynamically make divs that are clickable. I have inserted a
I am trying dynamically to append an <svg> element to an existing SVG island
I'm having issues trying to append dynamically created html inside a SimpleModal box (OSX
I'm trying to dynamically create a div to show error messages using jquery. I'm
I'm trying to dynamically segment each generated-label and hardcoded input pair with div tag's.
I am trying to dynamically insert a set of script tags with some javascript
I am trying to dynamically generate content using JSP. I have a <c:forEach> loop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.