I always thought there was a better way to access the dom. This is a tool that allows you to use extremely simple syntax to access dom elements. It makes an object with the name of your choice (I chose "$") that contains a reference to all elements that have an id.
example:
<script> $.foo.innerHTML = "Hello world" </script>
You can even choose to use an object that already exists (I chose "document" because it makes sense)
document.foo.innerHTML = "Hello world"
If you want to live dangerously, you can even make everything global!
foo.innerHTML = "Hello world"
You mixed up
b
andd
in that code snippet, but other than that all good!I thought about
d[i].id||'?'
since?
is not a valid ID for HTML elements, that could work OK, but it still feels a bit dirty.Speaking of dirty, what do you guys think of:
which you use like this:
What do you guys think of that ?