i am learning Jquery and i can't figure out why none of the JQuery lines execute, while javascript lines do. When I open it whith browser, the console shows"hello world" and "undefined". If i put these lines in the console, they are executed as expected. here is my code :`
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title> cim </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> $('div:nth(0)').attr("class","marked") </script>
<script>
$(document).ready(funk())
function funk() {
$("div").css("border", "3px solid red");
console.log("hello world");
$("div:nth(0)").attr("class","marked");
console.log($("div:nth(0)").attr("oo"));
$("div").append("LLLLLLLLLLLLLLLLLLLLL");
}
</script>
</head>
<body>
<div oo="ooo">
<p> blah </p>
<p> blah <br></p>
<p>blah</p>
</div>
<div>
<p> asd</p>
<p> asd</p>
<p > asd</p>
</div>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</body>
</html>enter code here`
$(document).ready(funk);notfunk()- you're calling the function when you include().</head>but no<head>></script>tags for the call to jQuery. Move$('div:nth(0)').attr("class","marked")to the script where the rest of your code is, within thereadyfunction,