Hi all,
I usually work on website back-ends and I'm not an expert in js, but circumstances are pushing me to understand it better. I have to make updates to a web page and I found the following code:
html:
<a href='javascript:void(0)' id='extra'></a>
js:
$("#extra").on('click',function(){
...
})
css:
#extra {
...
background: '/images/extra_image.png'
}
The aim is to display an image and have a javascript function called when it is clicked. The method used here seems very convoluted to me. What comes to mind for me would be:
html:
<img src='/images/extra_image.png' onclick='perform_image_click_stuff()' />
js:
function perfrom_image_click_stuff() {
...
}
Does the developer that wrote this code need some help or am I missing something here?