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

  • Home
  • SEARCH
  • 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 6836993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:25:23+00:00 2026-05-26T23:25:23+00:00

index.php i am using: <script src=srcipt.js></script> <div id=demo> <h3><input type=hidden name=id value=’1′ />test1</h3> <h3><input

  • 0

index.php i am using:

<script src="srcipt.js"></script>
    <div id="demo">
        <h3><input type="hidden" name="id" value='1' />test1</h3>
        <h3><input type="hidden" name="id" value='2' />test2</h3>
        <h3><input type="hidden" name="id" value='3' />test3</h3>
        <h3><input type="hidden" name="id" value='4' />test4</h3>
        <h3><input type="hidden" name="id" value='5' />test5</h3>
    </div>

in script.js

$(document).ready(function(){
    $('#demo h3').click(function(){
       var id = $(this).parent().find('input[type="hidden"][name="id"]').val();
       alert(id);
    });
});

When I click on “test1” result 1
, click on “test2” result 1
…
, click on “test5” result 1

How to get value when click on “test2” is result 2, how to fix it ?

  • 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-05-26T23:25:23+00:00Added an answer on May 26, 2026 at 11:25 pm
    $(document).ready(function(){
        $('#demo h3').click(function(){
           var id = $(this).children('input').eq(0).val();
           alert(id);
        });
    });
    

    That should work!

    $(this) refers to your h3 element. Why would you go to the parent first to search for an input? You can just get the first input element of the selected h3 element!

    Also, please note that give multiple input elements the same name is a bad practise in most cases.

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

Sidebar

Related Questions

I have index.php like this: <script type=text/javascript src=jquery-1.4.2.js></script> <script type=text/javascript src=ajax.js></script> <a href='one.php' class='ajax'>One</a>
I'm using the following htaccess script so that I can hide index.php from the
I'm using Firefox 3.6.6. I have a PHP script called index.php with the following
if i have submitted the iphone WebApp at https://adcweb.apple.com/iphone/index.php using ADC Account. i want
I'm using Facebook Connect's Comments Box ( http://wiki.developers.facebook.com/index.php/Comments_Box ) to handle comments on my
I am using these rules and conditions in .htaccess to turn these http://www.example.com/index.php/about/history http://www.example.com/about/history/index.php
I am using a login system. When I navigate to comments/index.php without logging in,
i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe
I've built a search index using the PHP Zend Framework Search (based on Lucene).
i'm using a php script for redirection after detecting the search word to my

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.