首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery原生事件不响应,该怎么处理

2013-12-06 
jquery原生事件不响应htmltitleindex/titleheadmeta nameviewport contentwidthdevice-wid

jquery原生事件不响应


<html>
<title>index</title>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<meta content="text/html;charset=utf-8" http-equiv="content-type"/>
<link rel="stylesheet" href="resources/css/flexslider.css" type="text/css" media="screen" />
<link href="resources/css/jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css" />
<script src="resources/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="resources/js/jquery.mobile-1.3.2.js" type="text/javascript"></script>
<script src="resources/js/jquery.flexslider.js"></script>
<link rel="stylesheet" href="resources/css/demo.css" type="text/css" media="screen" />
<style>
*{padding: 0;margin: 0}
.left{ float: left;width: 50%;position: relative; }
.right{ float: right; width: 50%;position: relative;}
.left img{position: absolute; width: 100%;height: 100%}
.right img{position: absolute;width: 100%;height: 100%}
.parent{background: #000000;padding: 0px!important;}

</style>
</head>
<body>

<div id="container" data-content="header">
<div class="flexslider">
    <ul class="slides">
    <li>
    <img src="resources/images/inacup_donut.jpg" />
    <p class="flex-caption">Captions and cupcakes. Winning combination.</p>
    </li>
    <li>
    <a href="http://flex.madebymufffin.com"><img src="resources/images/inacup_pumpkin.jpg" /></a>
    <p class="flex-caption">This image is wrapped in a link!</p>
    </li>
    <li>
    <img src="resources/images/inacup_donut.jpg" />
    </li>
    <li>
    <img src="resources/images/inacup_vanilla.jpg" />
    </li>
    </ul>
  </div>
    </div>
  
  <div class="parent">

    </div>
<script type="text/javascript">
var allwidth = $(window).width();
var current_img;
$(window).load(function() {
current_img = allwidth/2;
$('.flexslider').flexslider();
for (var i=0; i < 6; i++) {
  if(i%2===0){
  $('.parent').append('<div class="left" style="height:'+current_img+'px"></div>');
  $('.parent').append('<div class="right" style="height:'+current_img/2+'px"></div>');
 
  }else{
  $('.parent').append('<div class="right" style="height:'+current_img+'px"></div>');
  $('.parent').append('<div class="left" style="height:'+current_img/2+'px"></div>');
  
  }  
};
$('.left').each(function(index) {
  $(this).append('<img id="hihi" src="resources/images/fullscreen.JPG" />');
});

$('.right').each(function(index) {
  $(this).append('<img id="hihi" src="resources/images/fullscreen.JPG" />');
});
});
$(window).resize(function() {
  $('.left').each(function(index) {
  current_img = $(this).width();
  
  var current_background = $(this).css("background-color");
if(index%2==0){
$(this).css("height",current_img);
}else{
$(this).css("height",current_img/2);
}
$(this).css("background",current_background);
  });
  $('.right').each(function(index) {
  var current = $(this).width();
  current_background = $(this).css("background-color");
if(index%2==0){
$(this).css("height",current_img/2);
$(this).css("background",current_background);
}else{
$(this).css("height",current_img);
$(this).css("background",current_background);
}
  });
});

$('#hihi').click(function(){
  console.log(current_img);
  $(this).animate({
        height:current_img*0.75,width:current_img*0.75,
        left:$(this).width()/8,
        top:$(this).height()/8
     },1000);
});
</script>
</body>
</html>



点击执行动画没有效果?请问是什么原因


[解决办法]

引用:
我不是放在最后面吗?

请断点跟踪,你需要了解一下执行顺序。你的动态添加是放在window.onload事件内的

热点排行