Why some developers use,
<input type="button" onClick="javascript:function-name()">
instead of
<input type="button" onClick="function-name()">
Please help me to solve this matter.
Because they probably just don't know better and think they have to use javascript: whenever they use JS in an HTML attribute.
In an event handler attribute, javascript: is nothing but a label and is entirely useless.
However, it is necessary in href attributes, but it has a completely different meaning: It is a pseudo-protocol, which tells the browser to interpret the remainder of the "URI" as JavaScript.
(not to mention that using JS inside an href is considered bad practice)
function-name()won't work, the caracter-is not accepted in any JS name, it means "minus". Your function name is equivalent tofunction - name(). You should writefunction_name()orfunctionName().