开发者

Trying to post-load a div with jQuery

开发者 https://www.devze.com 2023-04-13 04:17 出处:网络
This should be fairly simple, but it\'s just not loading for me. Here\'s my html: <div id=\"accordion\">

This should be fairly simple, but it's just not loading for me. Here's my html:

<div id="accordion">

</div>

That's taken out of a WordPress page, if it 开发者_高级运维matters. Here's my jQuery, which is called in my header.php file. Here's the jQuery I have, not sure it's correct or not:

$('#accordion').load('/site/wp-content/themes/theme/acc.php');

I copied the information that used to be inside that div and stuck it in that external file. As I'm writing this, I'm going to check to make sure the path is correct, because it just hit me that that could easily be the problem.

Thanks guys/gals!

SOLVED :: Code was right, I was just calling the wrong .js file in my header!


you code looks correct. possible problems are:

  • the path is incorrect
  • you havn't wrapped you code in a domready-event:

    $(function(){ /* your code goes here */ });

  • some kind of javascript-error - use firebug or something similar to check this

please check this, and if you find a problem you can't solve on your own (a javascript-error you don't understand, for example) please update your answer with the additional information.


That's the correct syntax for what you want. Make sure you encase within $(document).ready() so it runs after the DOM is loaded like so:

$(document).ready(function() {
    $('#accordion').load('/site/wp-content/themes/theme/acc.php');
}
0

精彩评论

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

关注公众号