在Wordpress帖子中使用jQuery [英] Using jQuery in a Wordpress post

查看:83
本文介绍了在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.

这篇关于在Wordpress帖子中使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆