Jquery load jquery加载变量won';装载内容物

Jquery load jquery加载变量won';装载内容物,jquery-load,Jquery Load,您好,我正在使用jQuery load从链接中获取ahref,然后我想从页面中加载一个div,我正在进入一个div,因此我尝试了以下方法: // lets load the contents $('#navigationLinks a:not(:first-child)').click(function(event){ $('#wrapper').animate({ 'left':'0px' }); var href = $('#navigationL

您好,我正在使用jQuery load从链接中获取ahref,然后我想从页面中加载一个div,我正在进入一个div,因此我尝试了以下方法:

// lets load the contents
$('#navigationLinks a:not(:first-child)').click(function(event){

    $('#wrapper').animate({
        'left':'0px'
    });

    var href = $('#navigationLinks a').attr('href');
    $('#content').load(href + ' #resultDiv');

    event.preventDefault();

});
这是HTML:

<div id="navigationLinks">
    <a href="index.html" id="dashboardHome">Dashboard Home</a>
    <a href="industry-overview.html" title="Industry Overview" class="first currentLink">Industry Overview</a>
    <a href="regions.html" title="Regions">Regions</a>
    <a href="industries.html" title="Industries">Industries</a>
    <a href="security-pipeline.html" title="Security Pipeline">Security Pipeline</a>
    <a href="audit-events-issues.html" title="Audit Events &amp; Issues">Audit Events &amp; Issues</a>
    <a href="account-filter.html" title="Account Filter">Account Filter</a>
    <a href="contractual-delivered-services.html" title="Contractual vs. Delivered Services" class="last">Contractual vs. Delivered Services</a>
</div>

我尝试在#之前删除#resultDiv#中的空格,但没有帮助,任何帮助都将不胜感激。

您应该试试这个

$(document).ready(function(){

$('#navigationLinks a:not(:first-child)').click(function(e){
   var href = e.target;
   $('#content').load(href + ' #resultDiv');
   e.preventDefault();

});
});

问题是
var href=$('#导航链接a').attr('href')
将始终获取块中的第一个链接,而不是实际单击的链接。

很抱歉,我不知道答案,但您能否控制台.log()并确认所有部分都正常工作:1。事件触发2。href有效期为3。对内容的查询返回了什么?注意:您可以使用
var href=jQuery(this.attr('href')。更高效。var href=e.target;-通过将url加载到id为resultDiv的div中,这不起作用