Skip to content

Instantly share code, notes, and snippets.

@gordinmitya
Last active December 11, 2016 17:19
Show Gist options
  • Save gordinmitya/6cb6e687ded623fa65b56839949ba584 to your computer and use it in GitHub Desktop.
Save gordinmitya/6cb6e687ded623fa65b56839949ba584 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="task1">
<input id="t0" type="number" value="18.5"/>
</div>
<div id="task2">
<input id="t0" type="number" value="18.5"/>
</div>
<script>
function e(id, root){
return root.querySelector("#"+id);
}
var someVal;
function read(root){
someVal = parseFloat(e("t0", root).value);
}
function calc1(){
var task = e("task1", document); //Uncaught TypeError: e is not a function(…)
read(task);
var e = function(id){return e(id, task)}
console.log(someVal);
}
document.addEventListener("DOMContentLoaded",calc1);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment