【发布时间】:2012-01-14 07:51:30
【问题描述】:
今天我一直在这里向script寻求帮助。
成功完成——再次感谢 RKW。
我已将代码与我之前的代码合并,一切似乎都运行良好——在 FF 下。但现在,我已经在 Chrome、Safari (mac) 和 Opera 下尝试过了。 在 Chrome 和 Safari 中,脚本根本没有做任何事情(并且错误控制台保持清晰)。在 Opera 下,只有第一部分在工作——添加了 active 类。
有什么建议吗?
$(document).ready(function(){
$('input').focus(function() { /* add class active to parent div */
$('div').removeClass('active');
$(this).parent().parent().parent().addClass('active');
$(this).closest("div").addClass('active');
});
$('input:radio').focus(function() { /* add class highlight to specified tds in one column */
var num = 2;
var col = $(this).closest('td').index() + 1;
var row = $(this).closest('tr').index();
var tds = $('td:nth-child(' + col + ')');
tds = tds.slice(row,row+num);
$('td').removeClass('highlight');
tds.addClass('highlight');
});
});
【问题讨论】:
-
你应该发布你的 html 或者一个更好的 jsfiddle。真的很难根据你的 javascript 猜测你的 html 结构是什么。
-
我之前的帖子有一个链接,html在哪里。我尽量不要发布太多重复的内容...
-
如果您发布与问题相关的内容,您将获得更好/更快的答案。人们不喜欢为了理解您当前的问题而点击并阅读其他答案。
-
鉴于您提供的 HTML 布局,由于唯一的输入是单选按钮,您可以将所有代码放在 input:radio 或 input
-
mrtsherman:谢谢你的建议。我是这个网站的新手——我有很多东西要学。
标签: javascript jquery