简体   繁体   English

这个 onClick JavaScript 事件在 POST 部分不接受吗?

[英]Is this onClick JavaScript event is not accepting in POST section?

I am writing a blog post on my WordPress website and I need show following HTML code:我正在我的 WordPress 网站上写一篇博文,我需要显示以下 HTML 代码:

<button type=”button” onclick=”getData()”>Get Data</button>

Now, if I press the preview button then it's showing me Post Not Found Error message.现在,如果我按下预览按钮,它会向我显示 Post Not Found 错误消息。 Very strange?很奇怪? If I change the onClick to something else then it's working.如果我将 onClick 更改为其他内容,则它可以正常工作。 So I think the issues on the onClick event.所以我认为 onClick 事件的问题。

If you can then try to post above HTML code in your WordPres Blog Post editor and then press preview button :(如果您可以尝试在 WordPres 博客文章编辑器中发布上述 HTML 代码,然后按预览按钮 :(

Can you tell me how can I solve it?你能告诉我我该如何解决吗?

Thank You.谢谢你。

Updated:更新:

Maybe I can't explain my question properly :(也许我无法正确解释我的问题:(

I have a WordPress blog website where I am writing a tutorial about HMTL and CSS.我有一个 WordPress 博客网站,我正在写一篇关于 HMTL 和 CSS 的教程。 You know if you write a tutorial blog you need to show some textual code to the user, right?您知道如果您编写教程博客,您需要向用户显示一些文本代码,对吗?

Yes, I am doing the same thing.是的,我也在做同样的事情。 I need to write above HMTL code as textual version but when I press the preview button it's showing me Not Found Error Message.我需要将上面的 HMTL 代码写为文本版本,但是当我按下预览按钮时,它显示我未找到错误消息。

Note: It's not an actual JS function.注意:它不是一个实际的 JS 函数。

I have another code that's showing perfectly on the blog page.我有另一个代码完美地显示在博客页面上。 Check this image.检查此图像。

在此处输入图片说明

You can do this by this way please check below code example I have given.您可以通过这种方式执行此操作,请查看我提供的以下代码示例。

 $(document).ready(function(){ $("#getData").click(function(){ //Do some action }); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button type=”button” id="getData">Get Data</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM