jquery - 如图所示,我想要我的 td 中的 div

标签 jquery html css

我有这个 HTML 代码:

<table>
    <tr>
        <td>
            <p id="price">10000</p>
            <div class="no" hidden="hidden">Description</div>
        </td>
    </tr>
</table>

我的 jquery 代码是:

<script type="text/javascript">
    $(document).ready(function(){
        $("#price").live("mouseenter", function () {
            $(this).next("div.no").show();
        });
        $("#price").live("mouseleave", function () {
            $(this).next("div.no").hide();
        });
    });
</script>

现在我想要特定高度的标签。 让我用图片描述你:

鼠标进入前表格是这样的: enter image description here

进入鼠标后,上面的代码会变成这样: enter image description here

但是我想要的东西如下: enter image description here 我该怎么做?

最佳答案

也许这可以帮助你:

我使用悬停而不是实时,因为您正在重新创建“onElementEventMouse”,请在此处检查: http://jsfiddle.net/9bbz5/

HTML:

<table>
    <tr>
        <td>
            <p id="price">10000</p>
            <div class="no" hidden="hidden">Description</div>
        </td>
         <td>
            <p id="price">10000</p>
        </td>
         <td>
            <p id="price">10000</p>
        </td>
    </tr>
</table>

CSS:

#price {
    background-color: yellow;
    height:40px;
    width: 200px;
}
td {
    text-align: center;
}
.no {    
    background-color: red;
    padding: 15px;
    margin-top: -30px;
    width: 150px;
    position: absolute;
}

JS:

$(document).ready(function(){
  $("p#price").hover(
      function () {
        $(this).next("div.no").show();
      },
      function () {
        $(this).next("div.no").hide();
      });
  });

希望对您有所帮助!

关于jquery - 如图所示,我想要我的 td 中的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15616615/

相关文章:

css - 如何用phantomjs创建不同的A4页面

javascript - 在 xhr responseText 上执行 jQuery 操作

jquery - 为什么我的页面 div 会在 ios 上永远增长(仅限)?

javascript - 单击按钮删除div

html - anchor 标记内的中心图像

javascript - 平滑页面滚动 - 第一次点击滚动到错误的位置。第二个链接工作正常

javascript - 在不使用数据库的情况下登录网站

javascript - 正确总结if循环

jquery - jQuery .ajax 的缓存选项在 Firefox 和 Chrome 中不起作用?

html - 是否有任何 HTML 编码约定/样式/标准