is this what you would call "using the DOM"?, or is this a more basic javascript technique?
Not really, no. The DOM is being used (simply by working with elements), but "using the DOM" usually refers to DOM-specific and -standard functions such as getElementsByTagName, .parentNode, &c.
document.images -- okay, so it's an image element within the document. easy enough, and the ['id-of-image'] is essentially the associative Key of the Array named "Images"? depending upon the placement in the doc., i understand i could also use for example images['2'], if it were the 3rd element, etc.?
[2], yes. No quotes: it's a number, not a string. document.images isn't technically an array; it's what we call a collection, which is basically an object that usually behaves like an array, but not always.
my question for that part would be-- is it always going to be "document - element - attribute" ? (as in document.image.src)? obviously javascript then is not using precisely the same as html names (i.e. image.src vs <img src /> ). any advice for this issue?
document.image is not defined. document.images is a special collection of all the images within the document. This does not hold true for all elements. If no collection is available (window.frames and document.links also exist), then a reference to an individual element can be obtained using document.getElementById("id_of_element"), or a collection similar to document.images can be obtained with document.getElementsByTagName("tag_name"). The attributes generally keep the same names in Javascript that they have in HTML, although there are a few cases where this is not so. In Javascript, however, they are case-sensitive.
now, this was easy because it was all able to be done within the event handler itself, right? if i wanted to, i could put this in a .js file, or up at the top of the doc, and part of a <script>, yes?
Yes.
and if i did it that way, would it be something like this?:
No, closer to:
Code:
<script type="text/javascript">
function imgbryte(id) {
document.images[id].src = 'brightimage';
}
function imgdull(id) {
document.image[id].src = 'dullimage';
}
</script>
<!-- stuff -->
<a href="someurl" onmouseover="imgbryte('idname');" onmouseout="imgdull('idname');">somelink
</a>
assuming i'm doing "okay" w/ this stuff-- what might you suggest as a "next step" in terms of... maybe try to build some script, or have a look at something a little more complicated... such as ____ ?
No idea. What do you want to do?
Bookmarks