I know that you do not want the jQuery solution, but including javascript inside HTML, be great, no.
I mean, you can do this, but there are many reasons why you shouldn't (read on unobtrusive javascript if you want more details).
So, in the interest of other people who can see this question, here is a jQuery solution:
$(document).ready(function() { $('area').mouseover(function(event) { $('#preview').attr('src', 'images/' + $(event.srcElement).attr('id')); }); });
The main advantage is that you do not mix javascript code with HTML. In addition, you only need to write once, and it will work for all tags, and not to specify a handler for each separately.
An additional advantage is that each jQuery handler gets an event object that contains a lot of useful data - for example, the source of the event, the type of event, etc., which greatly facilitates writing down the type of code that you are using.
Finally, since this is jQuery, you donβt need to think about cross-browser materials - the main advantage, especially when working with events.
Gregory Mostizky Oct 02 2018-11-11T00: 00Z
source share