i imported my script
<script src="/test.js"></script>
and the content is
var test= $(document).find('aside#bar');
var list= test.find('ul');
then i using following script to append string
<script>
$(document).ready(function () {
$(list).text("testing message");
});
</script>
but chrome console says Uncaught ReferenceError: list is not defined
how can i use variable in jquery?
Update
i discovered all script is not work in that page
i use
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="/test.js"></script>
<script>
$(document).ready(function () {
$(document).html("testing message");
});
</script>
but nothing append,chrome console doesn't log anything
<script>tag?headelement or somewhere inbodybefore the elements you are trying to select in your first external script are actually existing in the document, then your variablestestandlistwill simple not reference any elements when you try to work with them in your later code that gets triggeredonready.