开发者

Jquery show() dynamically built element

开发者 https://www.devze.com 2023-01-31 14:35 出处:网络
I have a empty hidden div that will include information from an AJAX call.It works without the jquery show command, but I wanted to add the smooth opening of the div with jquery instead of the abrupt

I have a empty hidden div that will include information from an AJAX call. It works without the jquery show command, but I wanted to add the smooth opening of the div with jquery instead of the abrupt style="display: ''" approach. The command to open the div is on line 7 of the function. I took it out to get the jquery approach to work lower down in the function.

The code that I have that works is here:

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开发者_JS百科]);
    //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'); 
});
}

Am I using the wrong approach here? Thanks in advance!


Please change line

$("butShowImage_" + thumbs[0]).live('click', function () { (probably numbered 416) to

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

0

精彩评论

暂无评论...
验证码 换一张
取 消