I have .js Javascript file, inside which I reference CSS classes defined in a separate stylesheet file.
By referencing, I mean something like this:
.attr("class", "link")
where link is a class defined in the stylesheet file.
If I link both the .js and .css files above inside a .html file, would the styles be applied properly?
EDIT: what I've tried so far
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Graph Test</title>
<link type="text/css" href="../css/graph.css" rel="stylesheet">
</head>
<body>
<div id="graph-container">
<div style="width:700px; height:600px" id="graph"></div>
</div>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/d3/2.10.0/d3.v2.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="../js/graph1.js"></script>
</body>
</html>
graph1.js is the .js file in question, in which I reference classes from graph.css. Both files are present at specified locations, yet no styles defined in graphs.css is applied to the elements created by graph1.js.
Note: take off <!DOCTYPE html> eliminates the problem, but it's not a solution.
.addClassinstead of.attrto manipulate classes with jQuery.