简体   繁体   中英

jQuery how to load a div from a other page using load

I have a little project where I need to show items on one page from a other so I have a little categorie where you can click on. Then I pick the attr("href"); and set that to the page I would like to load. this works.
But how to add a <div> to it so I online load like the <div class="holder"></div> And not the whole div?
This is my function:

function setupCasesFilter() 
{       
    j(".casemenu a").click(function(e) {
        e.preventDefault();
        j("ul.casesholder").load(j(this).attr("href")); 
    });
}

Where I can add the class inside attr("href")); ?

If you want to load a specific div element from the url then use it this way:

j("ul.casesholder").load(j(this).attr("href") + " .holder"); 

What seems to me that you have a .holder div on the href page you are loading, so you can pass that div's class name which you want to load with a space for ex. page.html .holder .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM