<head>
<title> Slider </title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script src="./js/jquery.js"></script>
<script src="./js/javascript.js"></script>
<script src="./js/slider.js"></script>
</head>
<div class="subTab">
<ul>
<li><a>First</a></li>
<li><a>Second</a></li>
</ul>
</div>
<script>
// works here
$(".subTab").css("left", 500);
alert($(".subTab").position().left);
</script>
Content js/javascript.js:
$(document).ready(function()
{
$(".subTab").css("left", 500);
alert($(".subTab").position().left);
});
Problem:
changing and outputting the .position().left of .subTab works locally in the <script> tags, but not externally in js/javascript.js. Why?
css:
.subTab
{
z-index:12;
position:absolute;
background-color:black;
padding-right:10px;
border:1px solid #8C90FF;
border-top:0px;
}
inside slider, we have index.php and the folder called js.
I think you may be including your external file incorrectly.
Try loading it with two periods in the relative path.
Also try putting an alert in your javascript.js file to see if its actually getting loaded. Or you could use firebug to see if its loaded.
If you can post the directory structure of your project, I can give you a more concrete answer.
It also appears that your code is not properly formatted.
Try: