开发者

load background image from other page with jquery?

I want to load a background image from another ajax page and Im not really sure whats th开发者_如何学运维e best way?

In my index.html page I have the css background code and I want to load an image from another asp page.

My index.html file as it looks now:

<div id="bgimage" style="background-image: url(../images/theimage.jpg); background-repeat: no-repeat; background-position: center center; background-attachment:fixed;">

and the imagepage.asp page that gets the right image from the db.

<div id="menuimage">
<img src="..user_images/<%=folderName%>/menuimage/<%=rs("big_image")%>" id="themenyimage"/>
</div>

Any suggestions appriciated, thanks.


Something along the lines of

var temp_div = $('<div></div>');
temp_div.load('path.asp #menuimage', function() {
    $('#bgimage').css('background-image', temp_div.find('img').first().attr('src');
});

Can probably be optimised etc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜