Jquery show()动态构建元素

时间:2010-12-17 06:14:27

标签: jquery

我有一个空的隐藏div,它将包含来自AJAX调用的信息。它在没有jquery show命令的情况下工作,但我想用jquery而不是突然的style =“display:''”方法添加div的平滑开口。打开div的命令在函数的第7行。我把它拿出来让jquery方法在函数中降低工作。

我的代码是:

function showImage(IDS, selectedID){
    var adType = new Array();
    adType = IDS.split("_");
    var thumbs = new Array();
    var adID = thumbs[0];
    var picImage = document.getElementById(adType[0] + '_' + thumbs[0]);
    //picImage.style.display = '';
    //picImage.className = "picDetail";
        removeChildren(picImage);
        var picThumbs = document.createElement('div');
        arLen = thumbs.length;
        //alert(arLen);
        if(arLen > 2){
        for ( var i=1, len=arLen; i<len; ++i ){
            //alert(thumbs[i]);
            var thumbNail = document.createElement('img');
        thumbNail.src = "../images/listings/" + adID + "_" + thumbs[i] + "_sm.jpg";
        thumbNail.className = "thumbNails";
        thumbNail.id = adID + '_' + thumbs[i];
        picThumbs.appendChild(thumbNail);
        picImage.appendChild(picThumbs);
        addHandler(adID, thumbs[i], 1);
        }
        }
        var previewImageContainer = document.createElement('div');
        var previewImage = document.createElement('img');
        previewImage.id = 'full_' + adID;
        previewImage.src = "../images/listings/" + adID + "_" + "1_.jpg";
        previewImage.className = 'thumbNails';
        previewImageContainer.style.width = "700px";
        previewImageContainer.style.textAlign = 'center';
        previewImageContainer.appendChild(previewImage);
        picImage.appendChild(previewImageContainer);
        var closeButton = document.createElement('img')
        closeButton.src = '../images/close_pix.png';
        closeButton.id = 'close_' + adType[0] + '_' + adID;
        picImage.appendChild(closeButton);
        addHandler(adID, 'close_' + adType[0], 2);
         //"butShowImage_" + thumbs[0]) is the name of the buttom that corresponds  //to the particular trigger and (adType[0] + '_' + thumbs[0]) is the name of the div I want //to open.  

 $("butShowImage_" + thumbs[0]).live('click', function () {
 $("#" + adType[0] + '_' + thumbs[0]).show('blind', {}, '200'); 
});
}

我在这里使用了错误的方法吗?提前谢谢!

1 个答案:

答案 0 :(得分:0)

请更改行

$("butShowImage_" + thumbs[0]).live('click', function () {(可能编号为416)

$("#butShowImage_" + thumbs[0]).live('click', function () {