jquery and wordpress

≯℡__Kan透↙ 提交于 2019-11-29 12:37:29

It seems like you have to load the script using wp_enque_script. You can find the documentation for this function and for loading scripts in WordPress in general at the codex page for wp_enque_script. Furthermore, I found an article on Using jQuery with WordPress that provides sample code for the loading of the script and then the use of it.

If you look at the Codex documentation, it says:

The jQuery library included with Wordpress loads in "no conflict" mode.

So to be able to use the $() function as usual, you have to do

jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
});

For an example of what that looks like, look at step 2 of the Themocracy article linked above.

I'm pretty sure you'll be fine with these resources, hope they help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!