1
我在Firefox v6.0.2和IE7中运行此代码。在Firefox中,我选择单选按钮。然后点击测试。我得到一个字符串长度为。在IE7中,我得到的字符串长度为。请解释跨浏览器的这种差异string.length
<script type="text/javascript">
function TestMethod() {
var name;
var address;
var city;
var state;
var zip;
var indexor = 0;
$('input[name=radioBtnSet1]:checked').parent().siblings().each(function (i, cell) {
if (indexor === 0)
name = $(cell).text();
else if (indexor === 1)
address = $(cell).text();
else if (indexor === 2)
city = $(cell).text();
else if (indexor === 3)
state = $(cell).text();
else if (indexor === 4)
zip = $(cell).text();
indexor++;
});
alert(name.length);
alert('FACILITY NAME: ' + '|' + name + '|');
}
</script>
<input id="runTest" onclick="javascript:TestMethod();" type="button" value="Test"/>
<table id="someTable">
<thead>
<tr>
<th></th>
<th>Header</th>
<th class="DisplayNone"></th>
<th class="DisplayNone"></th>
<th class="DisplayNone"></th>
<th class="DisplayNone"></th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="radio" value=" HHH VALUE" name="radioBtnSet1" /></td>
<td style="text-align: left;"> HHH VALUE</td><td class="DisplayNone">200 SOME STREET DR</td>
<td class="DisplayNone">CITY</td><td class="DisplayNone">TX</td>
<td class="DisplayNone">75007-3726</td>
<td style="padding-left: 1em;">9/30/2011</td>
</tr>
</tbody>
<tfoot>
<tr>
<th></th>
<th></th>
<th class="DisplayNone"></th>
<th class="DisplayNone"></th>
<th class="DisplayNone"></th>
<th class="DisplayNone"></th>
<th></th>
</tr>
</tfoot>
</table>
为什么?我怎样才能让它们相当?
你需要空格前缀“HHH”吗? –
在人们可以有用地帮助你之前,你必须先解决这个问题,这个问题的代码中有很多不相干的东西。 –
是的,间距是必须的。如果需要,可以稍后减少。在路上 –