Accesing an input element by its value

Accesing an input element by its value

In a project repeated blocks are identified by an <input type="hidden" value="x" /> field.
To get an access to one of the block I wanted first access to that field.
My first problem is there and I will explain it by a micro-project (tested with Firefox only)

Here is the HTML code :

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf8" />
  6.     <meta http-equiv="Content-Style-Type" content="text/css" />
  7.     <meta http-equiv="Content-Script-Type" content="text/javascript" />
  8.     <link rel="stylesheet" href = "index.css" type="text/css"  />
  9.     <script type="text/javascript" src='Library/jquery-1.4.js'></script>
  10.     <script type="text/javascript" src='index.js'></script>
  11. </head>
  12. <body>
  13.     <div class ="pseudoFieldset" id="toutesUnions">
  14.         <div class="pseudoFieldset">
  15.             <input type="hidden" id="curUnion" value="1" />
  16.             <input type="hidden" class="idUnion" value="1" />
  17.             <p class="legend">
  18.                 <span id="nom">Cliquer</span>
  19.             </p>
  20.             Contenu
  21.         </div>
  22.     </div>
  23. </body>
  24. </html>

and here the javascript code wher is the JQuery question

  1. //meta http-equiv content-type charset=utf8
  2. function test(){
  3.     var $id = $('#curUnion').val();
  4.     var $objet = $('#toutesUnions > .pseudoFieldset').find('input[value=$id]');
  5.     var $test = $objet.val();
  6.     var $objet2 = $('#toutesUnions > .pseudoFieldset').find('input[value="1"]');
  7.     var $test2 = $objet2.val();
  8.     alert($test + " / " + $test2);
  9.     var $parent = '????' //Fielset parent immediat ?????
  10.     $html = $parent.html();
  11. }
  12. $(document).ready(function() {
  13.     $('#nom').click ( function () {
  14.         test();
  15.     });
  16. });

With $id = "1"  as shown  by the Javascript debugger (in Firefox)
where is the difference between find('input[value=$id]')  and find('input[value="1"]')
giving the alert  result  =>   undefined / 1

PS   If you want to test the micro project you will find it in the Test.zip joined

PS2  The following question would be : How to access the immediate parent pseudoFieldset to get its html code ?