在Wordpress帖子中使用jQuery

问题描述:

我想在我的Wordpress帖子中发布实时jQuery示例,因此需要能够在实际的帖子本身中包含工作代码.我已经关闭了所见即所得的编辑器和所有可能在我发布时弄乱了我的代码的设置.通过exec-php插件,我也能够使php代码在后台运行,但是

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>

允许发布的代码执行javascript是危险的.它的安全漏洞称为XSS. WordPress可能默认将剥离javascript标签作为安全预防措施.可能有一个设置可以更改此行为.

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.