判断是否引入jQuery,没有则引入

<script type="text/javascript">
	window.jQuery || document
		.write("<script src='${contextPath}/assets/js/jquery.js'>"
		+ "<"+"/script>");
</script>

 通过window.jQuery是判断当前页面是否有引入jQuery,当没有引入就继续执行下面的语句,有则不用。

 ||为逻辑判断。window.jQuery结果为true直接返回,结果为false则执行document.write。

posted @ 2019-02-14 15:28  你好哈  阅读(2411)  评论(0编辑  收藏  举报