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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:35:22+00:00 2026-06-06T14:35:22+00:00

In a project I have a stream for users, everyone can share and comment

  • 0

In a project I have a stream for users, everyone can share and comment on shares. I add comments on the fly to each share. The overall structure is as below:
enter image description here

I’ve recently heard that using numbers for IDs are not at all a good idea, coz they’re not supported in CSS. If I change it to a class I have a new problem: I wont be able to recognize which post has been clicked (If ID is not number then I wouldn’t be able to get that particular share ID).

The code I have in jQuery is something like below:

$("div.comment").click(function(){ // Add comment link
            var jusid = $(this).attr('id');
            var content = "<textarea name='txtcomment' class='txtcomment' cols='67' rows='7'></textarea><button name='btncomment' class='btncomment'>Submit</button><div class='closecomment'>Close</div>";
            $("div#after"+jusid).html(content);
            $("div#after"+jusid).find('.txtcomment').focus();
        });

It’s actually tangled, and I’m sure it will be a mess in the near future. What is the best way to do this? How to not have a number for IDs and moreover recognize which div with what ID number has been clicked? (We need to add that comment for that specific share)

  • 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-06T14:35:23+00:00Added an answer on June 6, 2026 at 2:35 pm

    If I understand you correct you don’t need id’s to do that.

    Sample html:

    <div>
        <h3>#1333</h3>
        <p>Lorem ipsum</p>
        <a class="comment" data-postid="1333">Add a comment</a>
    </div>​
    

    Sample Java Script:

    $("a.comment").click(function() {
        var $this = $(this),
            isOpen = !$this.next().length,
            $textarea;
    
        if (!isOpen) {
            $this.next().focus();
            return;
        }
    
        $textarea = $("<textarea/>");
    
        $this.after(
            $textarea
                .after(
                    $("<button/>")
                        .text("Submit")
                        .click(
                            {$textarea: $textarea, postId: $this.attr("data-postid")},
                            submitComment
                        )
                )
                .after(
                    $("<button/>")
                        .text("Close")
                        .click(/* maybe do something here? */)
                )
        );
    
        $textarea.focus();
    });
    
    submitComment = function (event) {
        var message = event.data.$textarea.val(),
            postId = parseInt(event.data.postId, 10);
    
        alert("Do something with these:\nComment: " + message + "\nPost Id: " + postId);
    };
    

    ​

    This will add a textarea and two buttons after the clicked comment-link (and focus on the textarea).

    Style to taste 🙂

    Here is a fiddle for you. (UPDATED)

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

Sidebar

Related Questions

I have some small project to stream video to android device. Streaming is done
In my current project I have data about colors. Each color is either a
I have a project for a client that will be using a YouTube comment
I am working currently on a web project where users can create image galleries
I have one page that generates png images on the fly,project is not over
I'm working on BOINC project. I have two users: boincadm and www-data (for apache).
I have a web project wherein I have various functions that either add values
The project i am working on is basically having a module for comments. Users
In my project, I have two type of users: job seekers and hiring managers.
I want to apply NTFS-Search to our project. Our project have to find 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.