开发者

JQuery .load issues

开发者 https://www.devze.com 2022-12-24 23:07 出处:网络
Afternoon all, Using the code below I\'m trying to load what is render by the clicked link in to #loader,

Afternoon all,

Using the code below I'm trying to load what is render by the clicked link in to #loader, this works but I don't want the whole page I would like just a selected DIV i.e. #photo.

Whats the right w开发者_开发知识库ay for this to be done?

$(function() {

$(".style_image a").live('click', function(event) { 
    $("#loader").load(this.href)
    .show();

    $.get(this.href, null, null, "script");
    return false;       

});
});

I've tried:

$("#loader").load('this.href', #photo)

and:

$("#loader").load(this.href #photo)

No success!

p.s. the #loader is originally hide in my css file.

Regards

Mr THOMAS


You can do it like this:

$("#loader").load(this.href + " #photo");

It needs to be part of the string, with a space in-between.

Also, I'd show it once loaded, like this:

$("#loader").load(this.href + " #photo", function() { $(this).show(); });

This prevents flicker of it showing then getting content in.


Try and use ('#element).attr('src','http://...');

it should work.

Thanks Jean

0

精彩评论

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