[英]Add jquery to Mganto pages inside admin panels [wysiwig editor]
How can I add jQuery code inside magento2 pages?如何在 magento2 页面中添加 jQuery 代码? For example I have a "Contact us" page.
例如,我有一个“联系我们”页面。 So I can edit the content inside contact us page by
所以我可以通过以下方式编辑联系我们页面内的内容
Login to Admin panel登录到管理面板
admin -> content -> Pages -> Contact us
I want to add some jQuery code.我想添加一些 jQuery 代码。
So I write所以我写
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
<script>
jQuery(function($){
$(".mybox").on("click", function(){
MY CODE *******
});
});
</script>
Here the problem is: I have to call <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
这里的问题是:我必须调用
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
Otherwise it will not work.否则它将无法正常工作。 How can I solve this?
我该如何解决这个问题?
ie. IE。 How can i add jquery code in wysiwig editor
如何在所见即所得编辑器中添加 jquery 代码
Magento 2 Uses Require js Magento 2 使用需要 js
Try using尝试使用
<script> require([ 'jquery' ], function ($) { $(".mybox").on("click", function () { console.log('your code starts here'); console.log('your code ends here'); }); }); </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.