I am trying to access a div element of an html element present in a .htc file shown below-
<div id="memberImage"></div>
from a javascript file which is shown below-
$('#memberImage').html('<h2>No Images to Display</h2>');
Now, when I am accessing this div element this code is executing without displaying anything in the UI and without any error also. But when I use
document.getElementById("memberImage").innerHTML="<h2>No Images to Display</h2>";
in the javascript file, the text is getting displayed.
I have imported all the relevant Jquery files in the .htc file -
<link rel="stylesheet" type="text/css" href="../../stylesheets/jquery.dataTables.css">
<script src="scripts/contactGlobalFunctions.js" type="text/JScript"></script>
<script src="scripts/contactStrings.js" type="text/JScript"></script>
<script src="scripts/ImagesListDT.js" type="text/JScript"></script>
<script src="scripts/callRest.js" type="text/JScript"></script>
<script src="scripts/jquery.dataTables.min.js" type="text/JScript"></script>
<script src="scripts/jquery-1.11.1.min.js" type="text/JScript"></script>
Moreover when I am using an html file in place of .htc file both the ways of accessing the div element from javascipt file is giving expected results.
HTML file contents -
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="jquery-1.11.1.min.js" type="text/JScript"></script>
<script src="callRest.js" type="text/JScript"></script>
<script src="datatableTest.js" type="text/JScript"></script>
<script src="jquery.dataTables.min.js" type="text/JScript"></script>
<script src="windowClose.js" type="text/JScript"></script>
<link rel="stylesheet" type="text/css" href="jquery.dataTables.css">
</head>
<body>
<input type="button" value="submit" onclick="callAjax();"/>
<div id ="memberImage"/>
</body>
</html>
My question is why the div element is getting accessed from an html file using JQuery(and also document.getElementById()) but not from .htc file?