It is too broad for SO and possibly even Off-topic. If the code is working and you're looking for optimization then
Code Review would be the right place to ask. Instead of using an onclick attribute, why not simply use a single function with either a switch statement or using the data-attribtue to provide information? —
tacoshy 51 secs ago