einScotchFitch einScotchFitch - 26 days ago 7
HTML Question

How can I all a JS function in a browser console if the JS function is included in the HTML?

HTML:

<script type="text/javascript" src="scripts/js/script.js"></script>


JQuery function here:

$(document).ready(function() {
function rnmtn(){
console.log("red");
}
});


How can I call
rnmtn();
in the console without it returning
undefined
- the script is not linked to an html object - I need it to function on its own.

Answer

Make your function

function rnmtn(){
  console.log("red");
} 

and call it in console by typing

rnmtn()