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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:29:36+00:00 2026-06-13T16:29:36+00:00

Most of the HTML in my web app is dynamically generated: I take an

  • 0

Most of the HTML in my web app is dynamically generated: I take an object and create a grid row for instance, something like this:

var TheHTML = TheHTML + '<div class="HiddenDiv">' + SomeObject.ID + '</div>';
TheHTML = TheHTML + ....
$('#SomeTableContainer').html(TheHTML);

That way, when the user clicks on that row, I can access the ID of the object represented on the row using .find('.HiddenDiv')

How can I instead use .data() to insert the ID of the object to the row and later retrieve it without reading the ID from the DOM?

Thanks.

  • 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-13T16:29:38+00:00Added an answer on June 13, 2026 at 4:29 pm

    custruct DOM in object way:

    $('#SomeTableContainer').children().remove();
    
    var TheHTML=($('<div>')
       .append($('<div>').html('my subdiv div').data('subid',1))
       .append($('<div>').html('my subdiv div1').data('subid',2))
    );
    TheHtml.data('id',id);
    TheHtml.bind('myevent',function(e){console.log($(this).data('id'));});
    $('#SomeTableContainer').append(TheHTML);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Within a C# / ASP.NET MVC web app, I would like to display HTML
I would like to create a web service from a simple invoice app I
My web-app has to deliver db-generated content by email. The HTML need not include
I know $_SERVER['DOCUMENT_ROOT'] returns the document root (most likely something like /home/user/public_html), but is
I am writing a web app with asp.net, c# and jquery. Most of the
So I'm building a web app using C#.NET, and would like to add a
I would like to build a mobile app, brewed from nothing more but html/css
Im working with django, building a web app. I have most stuff working. The
I'm working on a web app that is mostly static - just HTML/CSS/JS +
Most of you probably know the following problem: You edit an HTML, view the

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.