Using jQuery in a Wordpress post

我只是一个虾纸丫 提交于 2020-01-15 10:08:15

问题


I'm wanting to post live jQuery examples in my Wordpress posts, and so need to be able to include working code in the actual post itself. I've turned off the WYSIWYG editor and any settings which may mess up my code when I publish. I've also, through the exec-php plugin, been able to get php code working in-post, but this (admittedly old) article gave me the impression that Javascript (and by extension, jQuery), would work without a plugin.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script>
<script type="text/javascript">
$(document).ready(function(){

    $("#test").text("jimmy");

  });
</script>

<p id = "test"></p>

回答1:


It is dangerous to allow posted code to execute javascript. Its a security hole known as XSS. WordPress probably defaults stripping out javascript tags as a security precaution. There may be a setting you can change this behavior in.



来源:https://stackoverflow.com/questions/2075923/using-jquery-in-a-wordpress-post

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