dongxia19772008 2014-08-13 08:11
浏览 46

使用javascript加载内容时,为什么鼠标悬停功能不起作用?

Why mouse over function not work when use with javascript load content ?

mouse over function like this

Fiddle

i want to use function mouse over in page : test5.php but not work , How can i do ?

index.php

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


<script type="text/javascript">//<![CDATA[ 
$(window).load(function(){
$('#love-trigger').on({
    mouseenter: function(e) {
        if (e.target.id == 'love-trigger') $('#love-box').animate({
            top: '0px' , opacity: 1
    }, 100);   
        clearTimeout( $('#love-box').data('timer') );


                if (e.target.id == 'love-trigger') $('.notch').animate({
            top: '33px' , opacity: 1
    }, 100);   
        clearTimeout( $('.notch').data('timer') );


    },
    mouseleave: function() {
        $('#love-box').data('timer', 
            setTimeout(function() {
                $('#love-box').animate({
            top: '10px' , opacity: 0
    }, 100);
            }, 1000)
        );


                $('.notch').data('timer', 
            setTimeout(function() {
                $('.notch').animate({
            top: '35px' , opacity: 0
    }, 100);
            }, 1000)
        );



    }
});

});//]]>  

</script>




<style type="text/css">
#love-box{
    position: relative;
    opacity: 0;
    filter: alpha(opacity = 0);
    top: 10px;
}
</style>




<div id="love-box" class="love-box_text">
    Star Star
    <b class="notch"></b>
</div>

        <img src="http://www.i2symbol.com/images/symbols/stars/outlined_black_star_u272D_icon_256x256.png" id="love-trigger" style=" margin-left: 28px; height: 62px;"/>

<br>

this is fucntion on index.php (Show "Star Star" When mouse over)







<br><br><br><br><br>




<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var username = $("#username").val();
// you can check the validity of username and password here
$.post("test5.php",{username:username},        
function(data) {
   $('#results').html(data);
});
});
</script>
<div id="results" style=" width: 100%; ">
</div>

this is fucntion on test5.php (not work! How to do ?)

test5.php

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


<script type="text/javascript">//<![CDATA[ 
$(window).load(function(){
$('#love-trigger').on({
    mouseenter: function(e) {
        if (e.target.id == 'love-trigger') $('#love-box').animate({
            top: '0px' , opacity: 1
    }, 100);   
        clearTimeout( $('#love-box').data('timer') );


                if (e.target.id == 'love-trigger') $('.notch').animate({
            top: '33px' , opacity: 1
    }, 100);   
        clearTimeout( $('.notch').data('timer') );


    },
    mouseleave: function() {
        $('#love-box').data('timer', 
            setTimeout(function() {
                $('#love-box').animate({
            top: '10px' , opacity: 0
    }, 100);
            }, 1000)
        );


                $('.notch').data('timer', 
            setTimeout(function() {
                $('.notch').animate({
            top: '35px' , opacity: 0
    }, 100);
            }, 1000)
        );



    }
});

});//]]>  

</script>




<style type="text/css">
#love-box{
    position: relative;
    opacity: 0;
    filter: alpha(opacity = 0);
    top: 10px;
}
</style>




<div id="love-box" class="love-box_text">
    Star Star
    <b class="notch"></b>
</div>

        <img src="http://www.i2symbol.com/images/symbols/stars/outlined_black_star_u272D_icon_256x256.png" id="love-trigger" style=" margin-left: 28px; height: 62px;"/>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示