I have an webpage where I am displaying news comments dynamically, the “Comment” link is connected to an jQuery function which is displaying the comments for the news (..like show comments from news id = x)
But “onClick” handlers aren’t the best way or?
Thats my code in the moment :
echo '<li>';
echo "<a href='#' onClick='showhideComments({$news['id']});'>" .
$this->translate('INDEX_COMMENTS'). " ($count)". "</a>";
echo '</li>';
Any suggestions? (the link part is running in a foreach loop to set the right id)
Inline event handlers work. They are just a bad design decision for very large client applications, but there’s nothing wrong with using them if you use them properly (ex. return false;).
To answer your question, you can remove them by doing something like: