2016-12-11 88 views
1

我有iframe頁面,當你懸停時出現。我想改變這個點擊。不知何故,它不工作。Mouseenter&Mouseleave點擊

JS:

$('section div').mouseenter(function(){ 
    $(this).css('height', '80vh'); 
    $(this).css('width', '100%'); 
    $('#info').css('width', '100%'); 
}); 

$('section div').mouseleave(function(){ 
    $(this).css('height', '2.5vh'); 
    $(this).css('width', '100%'); 
    $('#info').css('width', '100%'); 
}); 

CSS:

iframe { 
    border: 0; 
    width: 100%; 
    height: 100%; 
    transition: 1s; 
    z-index: 2000; 
} 

#info { 
    position: fixed; 
    top: 0; 
    height: 80vh; 
    width: 100%; 
    transition: 1s; 
    z-index: 1; 
} 

section { 
    position: fixed; 
    bottom: 0; 
    width: 100%; 
    z-index: 2000; 
} 

HTML:

<body> 
    <section></section> 
</body> 

有時我試用制定出來,但僅在IFRAME本身(空白),因此沒有任何反應當iframe充滿內容時,也許這只是一個目標問題。

+2

哪裏是你的'click'代碼? – Xufox

+0

我所做的點擊代碼根本不起作用。這是我想要實現的點擊,而不是鼠標和鼠標滑輪:jsfiddle.net/T73A/tsq8h6pc – 73A

+0

非工作代碼需要在問題本身。 – Xufox

回答

0

我真的不明白你的問題,你的click代碼丟失。從我幾乎聽不懂,你可以用這個代碼實現這一目標:

$('section div').click(function() { 
 
    // This part is not really needed 
 
    if (this.state === undefined) { 
 
    this.state = 0; 
 
    } 
 
    // end of not needed part 
 
    if (this.state) { 
 
    $(this).css('height', '2.5vh'); 
 
    $(this).css('width', '100%'); 
 
    $('#info').css('width', '100%'); 
 
    this.state = 0; 
 
    } else { 
 
    $(this).css('height', '80vh'); 
 
    $(this).css('width', '100%'); 
 
    $('#info').css('width', '100%'); 
 
    this.state = 1; 
 
    } 
 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<style> 
 
    section { 
 
    margin: 10px; 
 
    } 
 
</style> 
 
<div> 
 
    <section> 
 
    <div style="background-color: red; height: 2.5vh; width: 100%"></div> 
 
    </section> 
 
    <section> 
 
    <div style="background-color: green; height: 2.5vh; width: 100%"></div> 
 
    </section> 
 
    <section> 
 
    <div style="background-color: blue; height: 2.5vh; width: 100%"></div> 
 
    </section> 
 
    <section> 
 
    <div style="background-color: black; height: 2.5vh; width: 100%"></div> 
 
    </section> 
 
</div>

+0

這是我想要實現的點擊,而不是鼠標和鼠標葉片:https://jsfiddle.net/T73A/tsq8h6pc/ – 73A

+0

我看到最新情況,div有更奇怪的hitbox,給我10分鐘 – Device

+0

好吧,所以錯誤是一樣的,div有一個更奇怪的hitbox。唯一的解決方法,我可以看到的是做一個處理器的div會觸發點擊事件。 – Device