I'm having an issue. I have a HTML page that has a javascript code and a jQuery code in the same script tag.
Here is my html with javascript and jQuery:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Page</title>
<!-- css -->
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/nivo-lightbox.css" rel="stylesheet" />
<link href="css/nivo-lightbox-theme/default/default.css" rel="stylesheet" type="text/css" />
<link href="css/animate.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet">
<!-- javascript and bootstrap -->
<script src="js/jquery.min.js"></script>
<link href="js/bootstrap.min.js" type="text/javascript">
<link href="js/modal.js" type="text/javascript">
<!-- template skin -->
<link id="t-colors" href="color/default.css" rel="stylesheet">
<script>
<!-- HERE IS SOME PURE JAVASCRIPT CODE -->
$(document).ready(function() {
var table = $('#tableBody tr td');
table.on("click",function() {
table.removeClass("test-class");
$(this).addClass("test-class");
});
});
</script>
My problem is: when the page loads, my jQuery function do not work, but when I copy this function and paste it on the browser's console, it works perfectly.
NOTE: when I put an alert on the browser's console it works. That means my jQuery is loading with the page.
What I am missing?
Thanks in advance.
tableelement on the page;.... or anything with that ID?