I am using this fancy little JavaScript to highlight a field as the user hovers over it. Could you please tell me if there is a way of adding an onclick function which will act as a link and go to a URL?

<script>
         $(function() {
            $('tr').hover(function() {
                $(this).css('background-color', '#eee');
                $(this).contents('td').css({'border': '0px solid red', 'border-left': 'none', 'border-right': 'none'});
                $(this).contents('td:first').css('border-left', '0px solid red');
                $(this).contents('td:last').css('border-right', '0px solid red');
            },
            function() {
                $(this).css('background-color', '#FFFFFF');
                $(this).contents('td').css('border', 'none');
                $('a#read_message.php').click(function(){ URL(); });
            });
        });
        </script>

推荐答案

try

 window.location = url;

Also use

 window.open(url);

如果你想在新窗口中打开.

Jquery相关问答推荐

JQuery DateTimePicker-在 Select 中抓取星期几

使用带有 Ajax GET URL 的数组在每次单击按钮时一次单步执行一个

如何使 Bootstrap 轮播滑块使用移动左/右滑动

jquery 淡入淡出元素不显示样式为可见性:隐藏的元素

如何使用 jQuery Select 所有复选框?

从 iframe 访问父窗口的元素

如何使用jQuery动态设置宽度和高度

Jquery .show() 不显示隐藏可见性的 div

如何在 jquery 中更新(附加到)href?

使用 jQuery 获取选定的选项 id

如何使用jQuery在弹出窗口中预览输入类型=文件中的选定图像?

使用 jquery 在 radio 上单击或更改事件

jQuery XML 错误请求的资源上不存在‘Access-Control-Allow-Origin’标头.

Jquery:如何判断元素是否具有某些 css 类/样式

消除移动 Safari 中点击事件的 300 毫秒延迟

jQuery - 从元素内部 Select 元素

为什么要使用发布/订阅模式(在 JS/jQuery 中)?

什么时候应该使用 jQuery 的 document.ready 函数?

将变量的值复制到另一个

IE 中带有 jQ​​uery ajax 调用的无传输错误