【发布时间】:2011-05-03 12:30:09
【问题描述】:
我尝试学习 jQuery。我观看了一段 Lynda 培训视频,其中包含以下代码
$("document").ready(function() {
$("form :checked").css("border", "3px solid red");
});
以上代码在 ie 和 opera 上可以正常工作,但在 firefox 和 webkit (chrome,safari) 上不能正常工作。
jquery 的版本是 1.3.2 。上面有什么问题?如何实现与表单选择器的跨浏览器兼容性?
编辑:html代码如下
<h1>
Example Form Document</h1>
<form action="" method="post">
<table class="style1">
<tbody>
<tr>
<td class="style2">
First Name</td>
<td>
<input id="FirstName" type="text" /></td>
</tr>
<tr>
<td class="style2">
Last Name</td>
<td>
<input id="LastName" type="text" /></td>
</tr>
<tr>
<td class="style2">
Disabled Element</td>
<td>
<input id="Text1" type="text" disabled="disabled"/></td>
</tr>
<tr>
<td class="style2">
Gender</td>
<td>
<input id="Male" type="radio" checked="checked"/>M<input id="Female" type="radio" />F</td>
</tr>
<tr>
<td class="style2">
What products are you interested in?</td>
<td>
<input id="Checkbox1" type="checkbox" checked="checked"/><label for="Checkbox1">Widgets</label><br />
<input id="Checkbox2" type="checkbox" /><label for="Checkbox1">Hibbity Jibbities</label><br />
<input id="Checkbox3" type="checkbox" checked="checked"/><label for="Checkbox1">SplashBangers</label><br />
<input id="Checkbox4" type="checkbox" /><label for="Checkbox1">Whatzits</label></td>
</tr>
<tr>
<td class="style2">
Comments:</td>
<td>
<textarea id="Comments" cols="40" name="S1" rows="5"></textarea></td>
</tr>
<tr>
<td class="style2">
Optional life story file</td>
<td>
<input id="File1" type="file" /></td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
<input id="Submit1" type="submit" value="submit" /> <input id="Reset1"
type="reset" value="reset" /></td>
</tr>
</tbody></table>
</form>
【问题讨论】:
-
你也可以显示 HTML 吗?
标签: jquery forms css-selectors cross-browser