久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在父div的鼠標懸停時顯示子div

How to show the child div on mouse hover of parent div(如何在父div的鼠標懸停時顯示子div)
本文介紹了如何在父div的鼠標懸停時顯示子div的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有許多父 div (.parent_div),每個都包含一個子 div (.hotqcontent),我使用循環從數據庫中輸出數據.

I have a number of parent divs (.parent_div), which each contain a child div (.hotqcontent) where I output data from my database using a loop.

以下是我當前的標記:

<div class="content">
  <div class="parent_div">
    <div class="hotqcontent">
      content of first div goes here...
    </div>
    <hr>
  </div>
  <div class="parent_div">
    <div class="hotqcontent">
      content of second div goes here...
    </div>
    <hr>
  </div>
  <div class="parent_div">
    <div class="hotqcontent">
      content of third div goes here...
    </div>
    <hr>
  </div>
  <div class="parent_div">
    <div class="hotqcontent">
      content of fourth div goes here...
    </div>
    <hr>
  </div>
</div>

我想要實現的是,當用戶將鼠標懸停/鼠標懸停在父 div 上時,應該顯示其中包含的子 div 的內容.

What I would like to achieve is when a user hovers / mouseovers a parent div, the contents of the child div contained within should be revealed.

為了實現這一點,我編寫了以下 jQuery 腳本,但它似乎無法正常工作.它甚至沒有顯示警報!

To achieve this I wrote the following jQuery script but it doesn't appear to be working. It's not even showing the alert!

<script> 
$(document).ready(function() {
  $(function() {
    $('.parent_div').hover(function() {
      alert("hello");
      $('.hotqcontent').toggle();
    });
  });
}); 
</script>

如何修改或替換現有代碼以實現所需的輸出?

How can I modify or replace my existing code to achieve the desired output?

推薦答案

如果你想要純 CSS,你可以這樣做......

If you want pure CSS than you can do it like this....

在下面的 CSS 中,在初始化/頁面加載時,我使用 display: none; 隱藏子元素,然后在父元素的 hover 上隱藏子元素,比如說有class parent_div,我使用 display: block; 來取消隱藏元素.

In the CSS below, on initialization/page load, I am hiding child element using display: none; and then on hover of the parent element, say having a class parent_div, I use display: block; to unhide the element.

.hotqcontent {
   display: none;
   /* I assume you'll need display: none; on initialization */ 
}

.parent_div:hover .hotqcontent { 
   /* This selector will apply styles to hotqcontent when parent_div will be hovered */
   display: block;
   /* Other styles goes here */
}

演示

這篇關于如何在父div的鼠標懸停時顯示子div的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
主站蜘蛛池模板: 亚洲成av人片在线观看 | 欧美一区二区三区在线播放 | 国产福利资源在线 | 成人欧美在线 | av黄色在线 | 精品久久久久久久久久久 | 2一3sex性hd| 国产精品成人一区二区三区 | 男女羞羞视频在线免费观看 | 午夜影视在线观看 | 国产精品一二三区 | chinese中国真实乱对白 | 精品成人在线 | 一区二区高清 | 欧美www在线观看 | 欧美精品乱码久久久久久按摩 | 亚洲+变态+欧美+另类+精品 | 中文字幕 国产精品 | 亚洲综合一区二区三区 | 国产在线观看 | 日本三级电影在线看 | 亚洲精品黄 | 国内精品免费久久久久软件老师 | 中文字幕日韩一区二区 | 久久伊人影院 | 欧美一级欧美一级在线播放 | 天堂视频中文在线 | 国产a视频 | a亚洲精品| 国产精品特级毛片一区二区三区 | 在线中文一区 | 91xxx在线观看| 91麻豆精品国产91久久久久久 | 日韩在线精品视频 | 精品国产18久久久久久二百 | 久久久精品一区二区三区 | 国产乱精品一区二区三区 | 国产在线中文字幕 | 天天操夜夜爽 | 欧美精品欧美精品系列 | 国产精品自产拍在线观看蜜 |