javascript - Exclude blank images in JQuery carousel -
i'm trying work bit of code pulls list of new book titles our library catalog , uses create jquery carousel. builds url image src each title using book's isbn number. issue not every book on new title list has isbn , don't have cover image. there can add make titles don't have cover image not added carousel? have limited jquery experience haven't been able figure out.
$.each( records.hitlisttitleinfo, function () { $("<img/>").attr("src", coverurlprefix + this.isbn[0] + coverurlsuffix).attr("alt", this.author).attr("title", this.title).addclass("cloudcarousel").appendto("#carousel1"); });
$(record.hitlisttitleinfo).not( function(index, element) { var isbn = this.isbn[0] return isbn == null || isbn.length == 0; // true means it's removed }).each( { $("#carousel1").attr("src", coverurlprefix + this.isbn[0] + coverurlsuffix) .attr("alt", this.author) .attr("title", this.title) .addclass("cloudcarousel"); });
Comments
Post a Comment