【发布时间】:2013-04-04 05:41:19
【问题描述】:
是否可以在 perl 的 here-doc 部分中包含 JQuery。 我试过但没有成功。 这是我的代码。
my $cgi = CGI->new();print header();print start_html("JQuery in perl");
print <<JS;
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script><!--
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
//--></script>
<p>Click to hide</p>
<p>Click to hide</p>
<p>Click to hide</p>
</body>
JS
print end_html();
但是当我写一个javascript函数时,它工作正常
my $cgi = CGI->new();print header();print start_html("hello");
print <<JS;
<script><!--
function show() {alert("Hello");}
//--></script>
<input type="button" value="Check" onclick="show()">
</body>
JS
print end_html();
我在这里遗漏了什么明显的东西吗?请提出建议。
【问题讨论】:
-
应该可以。如果您直接拨打
jQuery会发生什么。例如:jQuery.method()而不是$()。
标签: javascript jquery perl cgi heredoc