jquery加载以拉出特定图像

时间:2013-02-18 01:48:13

标签: jquery load

我正在尝试使用jquery加载,将特定图像加载到div中,这是我到目前为止所做的,并不是很有效:

$(document).ready(function () {  

$('#violin_img_1').load('http://www.klossal.com/klossviolins/inventory.html', function() {
    $(".violin:first").find('.photo').find('img');
});   


});
<。> .inventory页面中的div的结构如下:

<div id="bow_cello-VictorFetique_1093" class="iso bow bow_cello instrument_container">
    <div class="about background_notselected">
        <div class="about_txt">
            <div class="about_summary">
                <h3>
                    Price: $15,000
                </h3>
                <br class="spacer">
                <h3>
                        A fine French cello bow branded: Vtor FETIQUE A PARIS, sold with ETIENNE VATELOT certificate.
                        81 Grams, round reddish brown Pernambuco stick, silver winding, silver mounted ebony frog.   
                </h3>
            </div>
            <h1>
                 Victor Fetique, 1093
            </h1>
            <h2>
                Cello Bow
            </h2>
        </div>
    </div>
    <div class="tile">
        <img class="inventory_tile_img" src="http://www.klossal.com/klossviolins/tiles/inventory_tile.png" alt="">
    </div>
    <div class="photo">
        <img class="instrument" src="http://www.klossal.com/klossviolins/instruments/bows/cellos/VictorFetique_1093.jpg" alt="">
        <div class="enlarge bc">
            <img class="enlarged_unselected" src="http://www.klossal.com/klossviolins/elements/fullscreen_unselected.png"/>
            <img class="enlarged_selected" src="http://www.klossal.com/klossviolins/elements/fullscreen_selected.png"/>
            <div id="VictorFetique_1093" class="enlarged_txt">Enlarge Image</div>
        </div> 
    </div>
</div> 

1 个答案:

答案 0 :(得分:4)

如果您想要访问该元素,您应该像这样加载它:

$('#violin_img_1').load('http://www.klossal.com/klossviolins/inventory.html .violin:first .photo img')

你也是同一个域名吗? :

  

由于浏览器安全限制,大多数“Ajax”请求都是主题   同源政策;请求无法成功检索   来自不同域,子域或协议的数据。

link