(! note: I already looked at this site and in others the answer but I did not find the solution to my problem. Here are some questions I tried to use:
Why are you giving "Uncaught ReferenceError: getSetorObj is not defined"?
Function not set with javascript
JAVASCRIPT - Function does not load
I have the following problem: I have 2 files, one containing html5 and the other javascript. But when trying to use the "onclick" event in a "li" to call a function in my javascript file the function simply does not work, when checking my console I came across the following error line in javascript:
ReferenceError: openphoto is not defined
I have already checked the path to the javascript file, and also tried to change the position of my "script" tag to the end of the "body", but nothing changes.
HTML (relevant code only):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Mycode</title>
<script src="Javascript/javascript.js" type="text/javascript"></script>
</head>
<body>
<div id="layout">
<main>
<section>
<p>Vamos as fotos!<br/></p>
<ul id="dpf">
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto1.jpg"></li>
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto2.jpg"></li>
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto3.jpg"></li>
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto4.jpg"></li>
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto5.jpg"></li>
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto6.jpg"></li>
<li onclick="abrirfoto(this);"><img src="Backgrounds/Foto7.jpg"></li>
</ul>
</section>
</main>
<footer>
Copyright © by:<br>
Gabriel Rocha e Gustavo Rocha
</footer>
</div>
</body>
obs: in the whole code the attribute "alt" is used in the images.
Javascript (that's just it (I'm learning (report any error ° - °)))
function abrirfoto(myElement) {
myElement.style.width = 300px;
}
I'm using FF 47.0, already tested in chrome also (I do not know which version); if you need any information, please comment.
Edit: Now I noticed another error in the console (I do not know if it is relevant):
SyntaxError: identifier starts immediately after numeric literal
I also tried to put my function inside the script of my html5, but of the same error.