UPDATED:
Thanks for some good feedback. I did have multiple faults in my code, but
My problem was actually with a string in my code inside my jquery/javascript functions (that I did not post here, because I didn't think of it as faulty)
Faulty string:
var deleteAnswer = prompt("Are you sure you want to delete this project?\nName: "+<?=$project['projName']?>+"\nCompany: "+<?=$project['compName']?>);
Correct string:
var deleteAnswer = prompt("Are you sure you want to delete this project?\nName: <?=$project['projName']?>\nCompany: <?=$project['compName']?>");
I will also switch to only use document.ready, instead of window.load
And I use Firefox, but will start to check for errors in F12 console -> errors
JSHint was also a nice tip, as I can check my code there.
Thanks a lot for your feedback guys! =)
I've been using javascript and jquery on my page now, and it's been working good until now.
For some reason none of my code inside my <script> tag will fire anymore. Maybe I'm missing something important.
I've removed some of the code but I hope this is enough information. I've checked the source code to see if it's pointing to the right js file, and it is.
Also, adding this code right before <title> also works:
<script type="text/javascript">
$(document).ready(function(){
$("div").css("border", "3px solid red");
});
</script>
Anyways, here's parts of my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--<script src="jquery-1.10.2.min.js"></script>-->
<script src="jquery/jquery-1.9.1.js"></script>
<script src="jquery/ui/jquery.ui.core.js"></script>
<script src="jquery/ui/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="jquery/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>title goes here</title>
</head>
<body>
<script>
<!-- ########## WINDOW.load ############### -->
$(window).load(function(){
$('#topBarWrapper').hover(function() {
$('#topBarDropDown').stop();
$('#topBarDropDown').animate({top:'-30px'});
}, function() {
$('#topBarDropDown').stop();
$('#topBarDropDown').animate({top:'-60px'});
});
$('#deleteProjectBtn').click(deleteProject);
$('#cancelProjectBtn').click(cancelProject);
$( "#datepicker" ).datepicker({ dateFormat: "yy-mm-dd" });
});
function someFunction(){
//do something
}
function cancelProject(){
window.location = 'admin.php';
};
<!-- ########## DOCUMENT.ready ############### -->
$(document).ready(function(e) {
alert("document is ready");
var myCompSelector = document.getElementById('fcompanySelection');
myCompSelector.selectedIndex = parseInt(<?=$project['companyID']?>)-1;
var myCatSelector = document.getElementById('category');
myCatSelector.selectedIndex = parseInt(<?=$project['categoryID']?>)-1;
});
</script>
<!-- ########## WINDOW.load ############### -->isnt that the format for comments in HTML? You should use// ########## WINDOW.load ###############$(window).load()(fyi)? as usual : any console error (F12)?