Featured post
What exactly are parameters in javascript (or any programming language for that matter) -
i have piece of code i've written , read in order work correctly must use parameters did , works perfectly, cant figure out life of me parameters , how work. read through ton of articles on web couldn't figure out how parameters work. how 1 parameter know grab instructions another. whole idea frustrating. kind of side question. can getelementby class instead of id or there similar getelementbyid()
classes? in advance.
below code in script.js file:
function setvalue(field) { if(''!=field.defaultvalue) { if(field.value==field.defaultvalue) { field.value=''; } else if(''==field.value) { field.value=field.defaultvalue; } } }
and called script run code below:
<textarea id="info" class="textarea" name="comment" cols="40" rows="10" onfocus="setvalue(this)" onblur="setvalue(this)"> whats name </textarea>
parameters
if "parameter" mean "argument", it's not @ clear mean "how 1 parameter know grab instructions another." arguments/parameters don't grab "instructions" each other.
since it's not @ clear you're asking here, won't go kind of detail, warn function arguments work bit differently in javascript in many other languages c, c#, or java.
the traditional model special memory area called "stack": caller pushes arguments onto stack, , callee (the function being called) pulls them off stack.
javascript doesn't use stack model, though. instead, when function called, object called execution context allocated, , along called variable object, , arguments (and few other things) end being properties on variable object. (this happens invisibly behind scenes, don't direct references either object, fact of them clear edge case behaviors.)
getting elements class name
there's getelementsbyclassname
widely-supported except ie. if search "getelementsbyclassname
ie" you'll find variety of implementations ie can drop page.
- Get link
- X
- Other Apps
Comments
Post a Comment