0

これは私のhtmlコードです:

<div class="viewPopup login-popup"  id="login-box">
     <a href="#" class="close"><img src="images/close.png" class="btn_close" title="Close Window" alt="Close" /></a>
     <h6 class="h6">Task Name</h5>
     <div class="info">
      <p class="name">Assigned to </p>
      <p class="cont1"> Kumar</p>
     </div>
     <div class="info">
      <ul>
      <li><p class="name">Task </p></li>
      <li><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec condimentum est ut dolor aliquam sit amet suscipit urna vehicula. Nunc dolor massa, viverra commodo gravida sed, sodales et metus. Maecenas lacinia facilisis semper. Pellentesque ac tellus lacus.</p></li>
      </ul>

     </div>
     <div class="info">
      <p class="name">Starting Date </p>
      <p class="cont1"> 19/12/2012</p>
     </div>

     <div class="info">
      <p class="name">Ending Date </p>
      <p class="cont1"> 22/12/2012</p>
     </div>
</div>

<a href="#login-box" class="login-window" title="View">
    <input type="text" name="review_id" id="review_id" value="10" />
    <img src="images/eye.png" >
</a>
<a href="#login-box" class="login-window" title="View">
                        <input type="text" name="review_id_txt" id="review_id_txt" value="10" />
                        <img src="images/eye.png" >
                   </a>

これは私のjqueryコードです:

// JavaScript Document
$(document).ready(function() {
    $('a.login-window').click(function() {

                //Getting the variable's value from a link 
        var loginBox = $(this).attr('href');

        //Fade in the Popup
        $(loginBox).fadeIn(300);

        //Set the center alignment padding + border see css style
        var popMargTop = ($(loginBox).height() + 24) / 2; 
        var popMargLeft = ($(loginBox).width() + 24) / 2; 

        $(loginBox).css({ 
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
        });

        // Add the mask to body
        $('body').append('<div id="mask"></div>');
        $('#mask').fadeIn(300);

        return false;
    });

    // When clicking on the button close or the mask layer the popup closed
    $('a.close, #mask').live('click', function() { 
      $('#mask , .login-popup').fadeOut(300 , function() {
        $('#mask').remove();  
    }); 
    return false;
    });
});

ここでは、その jquery コードでテキスト ボックスの値を取得したいと考えています。

これは、タグreview_idに含まれるテキストボックスがあることを意味します。<a></a>

だから私はこの`タグを使ってテキストボックスの値を取得したい.

私はこのコードを知っています:

$("#review_id").val();

しかし、実際にはそれに基づいてテキストボックスの値を取得します<a>

これどうやってするの?

出来ますか?

編集:

<?php for($i=0;$i<5;$i++){?>
<a href="#login-box" class="login-window" title="View">
                        <input type="text" name="review_ids" id="review_<?php echo $i;?>" value="<?php echo $i;?>" />
                        <img src="images/eye.png" >
                   </a>

これにより、5 つ<a>のタグと 5 つのテキストボックスが作成されます。次に、テキスト ボックスの値を取得するにはどうすればよいですかreview_ids...

4

3 に答える 3

2

このようにしてみてください:

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <meta name="author" content="gencyolcu" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
 $('a.login-window').click(function() {
          var valuet=   $(this).find("#review_id").val();
          alert(valuet);
});
</script>
    <title>Untitled 1</title>
</head>

<body>

<a href="#login-box" class="login-window" title="View">
                        <input type="text" name="review_id" id="review_id" value="10" />
                        <img src="images/eye.png" >
                   </a>


<a href="#login-box" class="login-window" title="View">
                        <input type="text" name="review_id" id="review_id" value="10" />
                        <img src="images/eye.png" >
                   </a>



<a href="#login-box" class="login-window" title="View">
                        <input type="text" name="review_id" id="review_id" value="10" />
                        <img src="images/eye.png" >
                   </a>


<a href="#login-box" class="login-window" title="View">
                        <input type="text" name="review_id" id="review_id" value="10" />
                        <img src="images/eye.png" >
                   </a>


</body>

</html>
于 2012-10-20T04:47:44.670 に答える
1

試してみてください

$(".login-window").find("#review_id").val()

Jsフィドル

于 2012-10-20T04:36:18.063 に答える
0

あなたはシャープを逃した

$("#review_id").val();
于 2012-10-20T04:34:51.883 に答える