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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:26:22+00:00 2026-06-11T17:26:22+00:00

I have following code: <div id=comments class=clearfix> <div class=conversation box_round_s box_shadow clearfix mtm> <div

  • 0

I have following code:

<div id="comments" class="clearfix">
  <div class="conversation box_round_s box_shadow clearfix mtm">
  <div class="conversation box_round_s box_shadow clearfix mtm">
    <input class="conv_tracker" type="hidden" value="4695f1db2d">
    <div class="conv-header">2</div>
    <div class="comment pts plm prs pbs">
    <div class="comment plxl pts plm prs pbs">
    <div class="replybox pvs clearfix">
      <textarea class="comment_txt_r fses fft"></textarea>
    </div>
  </div>
  <div class="conversation box_round_s box_shadow clearfix mtm">
  <div class="conversation box_round_s box_shadow clearfix mtm">
</div>

and I’m trying to read the value of input with class conv_tracker (4th line in code with value=”4695f1db2d”). I want to read this value. I’m reading it when someone presses enter in textarea. there are multiple text areas on page. I’m using following jquery:

the code does enter inside the if, but shows undefined.

$(".comment_txt_r").keydown(function(e){
  var code = (e.keyCode ? e.keyCode : e.which);
  if(code == 13) {      
    var ctext = $(this).val();
    var relid = $(this).closest('.conversation').children('input.conv_tracker').val();
    alert(relid);
  }
});

can anybody please tell me what I’m doing wrong?

  • 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-11T17:26:23+00:00Added an answer on June 11, 2026 at 5:26 pm

    Use $('#conv_tracker').val(). The ID must be unique within the page, so there is no reason to traverse up and down the DOM via closest and children, and then select by ID. Just select by ID.

    It’s very likely that if your current code isn’t working, the ID is not unique within the page, and it’s being stripped off the later elements with duplicate IDs preventing your code from selecting the element. If this is the case, you need to use a class or some other attribute for the repeated elements.


    As an unrelated suggestion, try using data attributes and attaching the value directly to the element you’re binding the events to, rather than dumping random, uncoupled, semantically meaningless elements into the DOM.

    Your text area gets a data-conv-tracker attribute:

    <textarea class="comment_txt_r fses fft" data-conv-tracker="4695f1db2d" />
    

    And your code is simplified drastically with no additional selection/DOM traversal:

    if(code == 13) {      
      var ctext = $(this).val();
      var relid = $(this).data('conv-tracker');
      alert(relid);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html code : <div class=submit><input type=button name=getResult value=Get Comments class=sbutton
I have the following divs: <div class=vote> <input type=hidden name=reply-id value=83743> <a class=vote-up-0 title=Vote
I have following code in html: <div> <div style=float:left;margin:0.5em> <span class=title>Label1</span><br/> <input type=text name=name1
I have the following code: <div id=comments> <h2> Comments</h2> <div id=comment> </div> <% foreach
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following code: <div class=product> <div class=description></div> <div class=image></div> </div> <div class=product>
i have the following code <div class=hitarea expandable-hitarea></div> <span class=folder>level 1</span> <ul style=display: none;>
I have the following code: <div style= class=skiptranslate> <iframe frameborder=0 style=visibility:visible src=javascript:'' class=goog-te-banner-frame skiptranslate
I have the following code: <div id=content> <?php if(count($app->getMessageQueue())) { ?> <jdoc:include type=message />
I have a following code: <div class=block review_block wrap><ul class=comments_list> <li class=comment> <div class=poster>

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.