如果页面中尚未包含 jquery,我想将其包含在文件中。我怎样才能做到这一点?
我写了这个,但它给出了不想要的输出。
<script type="text/javascript">
if ('undefined' == typeof window.jQuery) {
// jQuery not present
// alert("Jquery Unavailable");
<?php echo '<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>'; ?>
} else {
// jQuery present
alert("Jquery Available");
}
</script>