如何在asp.net mvc中为强类型视图创建一个jquery弹出气泡

嗨我正在尝试为asp.net中的数据库在强类型视图中创建的项目创建一个jquery弹出框 我找到了很多例子,但没有什么真正有用。任何帮助,将不胜感激。 以下是我的强类型视图的示例,其中包含表格列和表格列中的项目:
  <table>
      <tr>
          <th>
              name
          </th>

  <% foreach (var item in Model) { %>

      <tr>
          <td>
              <%= (item.name) %>
          </td>
      </tr>

  <% } %>

  </table>
    
已邀请:
将泡泡信息放在页面的某个位置,也许在div标签内。在div标签上放置一个类,使其(1)隐藏,(2)相对于td标签绝对定位。 接下来,在&lt;%= item.name%>的悬停或单击事件中,您将使用jQuery来显示()或隐藏()弹出窗口。
<style>
    .myTable td { position:relative; top:0; left:0; }
    .myBubble { display:none; position:absolute; top:-100px; background:#CCC; }
</style>

<table class="myTable">
    <tr>
        <th>name</th>
    </tr>
    <% foreach (var item in Model) { %>
    <tr>
        <td>
           <div class="myTrigger"><%= (item.name) %></div>
           <div class="myBubble">
               <%= item.description %><br />
               <%= item.publishDate %>
           </div>
        </td>
    </tr>
    <% } %>
</table>

<script>

    // presuming you've already included a reference to the jQuery library...

    $('.myTrigger').hover( function () {
        // show the adjacent bubble content
        $(this).parent().find('.myBubble').show();  
    },   
    function () {
        // hide the adjacent bubble content
        $(this).parent().find('.myBubble').hide();
    });

</script>
    

要回复问题请先登录注册