Would it be better to use the method reddit uses when placing a vote by using <a onclick="vote('4')"> or should I just add a class selector like <a class='vote-up' id='4'> or is the difference negligible?
Would it be better to use the method reddit uses when placing a vote
Share
If you only use a class, you will still need to use JavaScript to attach an event handler to process the vote.
So you don’t need to put the
onclickinto the markup, but you will need to assign theclickproperty to everything with the class:This can be done in
$(document).ready(), or using.on()to attach to newly created elements as well.