我这里有一个用于解决此问题的演示。
这个脚本使用了一些很酷的函数,但在IE10上却毫无反应。
我不知道哪一部分出了问题,是否有适用于IE10的Javascript调试器或者有人能看出我错在了哪里?
$(function (){
$('.roleCheck').click(function () {
var check = $(this).attr('id');
var id = check.substr(check.length - 1).toString();
var field = "#fieldSet" + id;
var oldCol = $(this).css("background-color");
if (oldCol == "rgb(139, 231, 156)") {
$(this).css("background-color", "#fc8b6a");
$(field).hide();
$(this).find('span').text("Show");
}
else {
$(this).css("background-color", "#8be79c");
$(field).show();
$(this).find('span').text("Hide");
}
});
});
以下是它的部分使用场景:
<div id="columns">
<div class="columns left">
<fieldset>
<legend>Filters and Controls</legend>
<div class="roleCheck" id="check0">
<span>Hide</span> Engineer
</div>
<br />
<div class="roleCheck" id="check1">
<span>Hide</span> Trainee Engineer
</div>
<br />
<div class="roleCheck" id="check2">
<span>Hide</span> Senior Engineer
</div>
</fieldset>
</div>
<div class="columns right">
<fieldset id="fieldSet0">
<legend>Engineer</legend>
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Info 1</td>
<td>Info 2</td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset id="fieldSet1">
<legend>Trainee Engineer</legend>
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Info 1</td>
<td>Info 2</td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset id="fieldSet2">
<legend>Senior Engineer</legend>
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Info 1</td>
<td>Info 2</td>
</tr>
</tbody>
</table>
</fieldset>
</div>
</div>
啊,使用Chrome作为默认浏览器进行编程的危险......