[英]Using jQuery in Wordpress inline script
I need to load a bootstrap modal when a page loads and was trying to do it the easy way of adding an inline script to handle the call. 我需要在页面加载时加载引导程序模式,并试图通过添加内联脚本来处理调用的简便方法。 For the life of me I cannot find any information whether or not this is even a possibility.
对于我的一生,我什至找不到任何信息,甚至这是否有可能。
FYI I've enqueued jQuery properly and use it in plenty of other scripts. 仅供参考,我已经正确地使jQuery入队,并在许多其他脚本中使用了它。
Keep getting jQuery is not defined
no matter what combination of things I try. 无论我尝试哪种组合方式,
jQuery is not defined
持续获取。
Here's a little snippet of something I've tried 这是我尝试过的一些内容
<?php if(isset($_SESSION['form-failed'])): ?>
<script type="text/javascript">
<!--
(function($){
$('#request-info').modal('show');
})(jQuery);
-->
</script>
<?php endif; ?>
If this is not a possibility, what would be the best way to get a modal to show on page load based on a session variable? 如果这是不可能的,那么基于会话变量获取在页面加载时显示的模式的最佳方法是什么?
$(window).on('load', function (){
$('#request-info').modal('show')
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.