Link to home
Start Free TrialLog in
Avatar of nagunpyo
nagunpyo

asked on

Any difference between onmouseover='src="img1.gif"' and onmouseover='this.src="img1.gif"'

I just realized that when I assign a function to an event, I've been randomly using either,
onmouseover='src="img1.gif"'
or
onmouseover='this.src="img1.gif"'

and either of them work just fine

Are there any differences in those two?
I see more people are using this.src=..., are there any problems with just doing src=...
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nagunpyo
nagunpyo

ASKER

Zvonko, I decleared a global variable named "src" and it still works without "this".  :-(
Sorry, you are right. I was to sure so I did not test before.
Now I see it:
<script>
var src = 42;
</script>
<img src="test2.gif" onmouseover='alert(src);src="smily.jpg"' >

The alert does show the image src and not the global var.

We can reopen this question and refund the points because you found the answer: the assignment methods are equivalent.