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 9005461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:09:04+00:00 2026-06-16T01:09:04+00:00

I need to select dynamic id using JQuery, and once I select it then

  • 0

I need to select dynamic id using JQuery, and once I select it then I need to do some action on it.

<input id="content_photos_attributes_1355755712119_image"   name="content[photos_attributes][1355755712119][image]" size="30" type="file">

The HTML contains both ID and Name attribute. I dont care which one I can select as long it is selected.
This is what I have tried so far, without success.

<script type="text/javascript">
jQuery.noConflict();
jQuery("#add_photo_product").click(function() {

alert("Handler foooor .click() called.");

//var field = $("input[id *= 'content_photos_attributes_']");
var field = $('input[name*="content"]');
alert (field);

});

The first selector works, and I can grab it easily. As soon as it is executed, then DOM is populated with the one that I can get hold of (Under HTML code).

I have tried various combinations, but it is always null.

How can I do this?

  • 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-16T01:09:05+00:00Added an answer on June 16, 2026 at 1:09 am

    try replace this

       jQuery("#add_photo_product").click(function() {
    

    by this

       jQuery("#content_photos_attributes_1355755712119_image").click(function() {
    

    you are not making the id which is shown in your html code

    to run you your test better do easy alert just to test if it works

    like that

        alert(1);     // this will alert 1
    

    EDIT2>

    if you have the id like a variable then you can also do it like that

       var myid = "content_photos_attributes_"+your_variable+"_image" ;
                 // note that your_variable is this which generates 1355755712119 
    
        jQuery("#"+myid).click(function() {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to select dynamic id using JQuery, and once I select it then
I need some help. I want to create a dynamic line chart using Google's
Im using the jQuery dynamic form plugin , but i need support for nested
I need to deal with the table name as a variable.Then I must using
I need to select node which has a specific value: <td class='formlabel'>Name:</td> So I
I have very long select query which i need to filter based on some
I am using Eric Hynds’ jQuery for a multi-select list. I have created the
At the moment I using a dynamic select to populate a dropdown. What I
The following code produces a dynamic dropdown box. <select name=parent> <?php $q = $admindb->getParentCategories();
I need to create some stored procedures that receive as parameter db name, table

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.