开发者

add External javascript file - Syntax issue

When i use the following syntax, the inline script is not executed. In Firebug not ab开发者_开发百科le to debug the code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" type="text/javascript" />

<script>
$(document).ready(function () {
$('#btn').bind('click', function () {
alert('hai');
});
});
</script>

but if i change the external file add script, it works fine. no issues at all.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" type="text/javascript" > </script>


You must close <script> tag.

W3.ORG:

Start tag: required, End tag: required


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" type="text/javascript"></script>

<script>
$(document).ready(function () {
$('#btn').bind('click', function () {
alert('hai');
});
});
</script>

script is html pair tag. You have to close it

BTW there's no reason to use https


the browser inserts the content from the url provided in the src attribute into the <script></script> tag. so if there is only a emtpy tag you can't insert anything


Your are closing the script tag too early. Remove the last slash from the first row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜