简体   繁体   English

选择表格行内的输入

[英]Select an input inside a table row

How can I show the div element with class .mynote once clicking on the input with id=title ?单击带有id=titleinput ,如何显示类.mynotediv元素? I tried the below code, but it doesn't work.我尝试了下面的代码,但它不起作用。

 $("#title").click(function() { $(".mynote").show(); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <table class="tall-table"> <tbody> <tr> <td class="tall-data"> <div class="tall-note"> <div class="mynote" style="display:none"> some text here </div> </div> </td> </tr> <tr class="tall-data"> <td class="tall-label"> text ... </td> </tr> <tr> <td class="tall-data"> <input name="title" id="title"> </td> </tr> <tr class="tall-data"> <td class="tall-label"> text ... </td> </tr> </tbody> </table>

$( 'input#title' ).on( 'focus', function() {
    $(".mynote").show();
}).on( 'focusout', function() {
    $(".mynote").hide();
});

http://jsfiddle.net/7u0r8dvw/ http://jsfiddle.net/7u0r8dvw/

<table class="tall-table">
<tbody>
  <tr>
    <td class="tall-data">
      <div class="tall-note">
      <div class="mynote" style="display:none">
      some text here
      </div>
      </div>
    </td>
  </tr>
  <tr class="tall-data">
    <td class="tall-label">
      text ...
    </td>
  </tr>
  <tr>
    <td class="tall-data">
      <input name="title" id="title">
    </td>
  </tr>
  <tr class="tall-data">
    <td class="tall-label">
      text ...
    </td>
  </tr>
</tbody>
</table>
<script>
    $(document).ready(function(){
        $("#title").click(function() {
            $( ".mynote" ).show();
        });
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM