日期:2014-05-16  浏览次数:20481 次

jquery中的each()不执行,是什么原因??
我想为名称为“.inputWithImge”的每个元素都执行函数,现遇到情况是:“.inputWithImge”元素如果是在当前页面是可以执行这个函数的,但如果“.inputWithImge”元素是在浮动层的情况下,是不执行这个函数的,相当于each()不执行,那现要如何来解决这个问题呢?(保证“.inputWithImge”元素在浮动层中是存在的),代码如下:

$(document).ready(function() { <!--input对象加小图标-->ready()在文档加载后激活函数
   $(".inputWithImge").each(function(){
   $(this).add($(this).next()).wrapAll('<SPAN class="imageInputWrapper"></SPAN>');
    }); 
});

------解决方案--------------------
$(this).next() ???
浮动的层离开了文档流,不存在下一个元素
------解决方案--------------------
function OpenWindow(winID, Tit, randId){
    //randId默认为0,有时为了动态取值,调用时可以动态指定其值,一般情况下,不需要此参数
    //hiddenLoginWindow();
    //隐藏页面,出现浮动层
    var offHeight;
    //document.all.tags("html")[0].className = "hiddens";
    //上面那句不兼容浏览器,需要的话改成下面的。eq(0)都多余,一个页面出现两个html标签?没用过
    $('html').eq(0).addClass('hiddens');
    //隐藏当前页面,页面背景变灰色
    offHeight = window.screen.height;
    var div = document.createElement("DIV");
    div.id = "drowsyDiv";
    //遮罩层.蒙胧层
    div.style.left = 0;
    div.style.top = 0;
    div.style.width = document.body.clientWidth;
    div.style.height = document.body.clientHeight;
    div.style.position = "absolute";
    div.style.display = "";
    div.style.zIndex = "100";
    div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
    div.style.backgroundColor = "#2A4A6B";
    document.body.appendChild(div);

    var div = document.createElement("DIV");
    div.id = "layer1";
    div.style.position = "absolute";
    div.onMouseDown = "catchFlyBar()";
    div.onMouseUp = "releaseFlyBar()";
    div.style.zIndex = "200";
    div.style.width = "692px";
    div.style.display = "none";

    var strHtml = "";
    strHtml += "<table border=0 cellpadding=3 cellspacing=0 class=tableW>"
   &