I’m trying jQuery for the first time on my website and it doesn’t work. I’ve been trying hundreds of things for about 10 hours now and today I have much more grey hair =). The most simple snippet I found is this one:
<script type="text/javascript">
$(document).ready(function () {
$("#msgid1").html("This is Hello World by JQuery 1<BR>");
});
$(function () {
$("#msgid2").html("This is Hello World by JQuery 2<BR>");
});
window.onload = function() {
document.getElementById('msgid3').innerHTML = "This is Hello World by JavaScript";
};
</script>
This is Hello World by HTML
<div id="msgid1">
</div>
<div id="msgid2">
</div>
<div id="msgid3">
</div>
I put that in my <body>. The result is :
This is Hello World by HTML
This is Hello World by JavaScript
And the jQuery calls don’t work for me. Maybe it has something to do with my <head>?
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" media="screen"/>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
What do you think?
Actually, I just found the solution.
There seems to be an issue whene these lines are not very next to each other
By simply changing the order of the lines, the two jQuery output lines suddenly appeared!
Thank you all for you help!