I want to turn my table rows into links using JS. I have it looking like this:
-
First of all, no javascript:
in event handlers - they contain JavaScript code, not an URL. It just works because javascript:
is a label in this case and thus not a syntax error.
Besides that, any editor with proper syntax highlighting would have shown you that you are breaking the quoting as you are using single quotes for the HTML attribute and inside the attribute.
Here's the fixed code:
Besides that, inline event handlers are dirty. Better attach them nicely using jQuery:
$('tr').click(function() {
location.href = 'url';
});
- 热议问题