Passing this.value to a function in JS and then changing that value
I'm writing a JS function that I would like to be used directly with an
onfocus event, and also within another function. The problem is that if I
pass the function this, then all of my function code needs to be
field.value. That causes a problem when I use it inside a function, since
the passed variable doesn't have a .value attribute.
My thought was then to just pass this.value to the function, so I could
just work with the data passed, whether it was a field value or a function
value. However, now it doesn't change the value of the original field.
Is there a good way around this, or do I just need to have two functions?
No comments:
Post a Comment