-1

这个 HTML 代码块,它形成了一个带有下拉列表作为元素的表格,可以正常工作。

<table border="0" summary="Error Models">
<tr>
<th>Ambiguity Resolution Options</th>
</tr>
<tr>
<td>
Strategy: 
<select name="strategy">
   <option value="off">OFF</option>
   <option value="float">Float</option>
   <option value="instantaneous">Instantaneous</option>

</select>
</td>
</tr>
</table>

当我尝试在此下拉列表中添加“Fix-and-Hold”选项时,如下所示:

<option value="fix-and-hold">Fix-and-Hold</option>

我收到一条错误消息,即使我更改了“fix-and-hold”值,它仍然存在。

据我所知,可以在 value 参数中分配的可能值没有限制。那么,是什么导致了这个错误呢?

我使用Tryit (W3schools)编辑器为测试目的编写 HTML 代码,因为我没有一个能够在不发布页面的情况下显示页面的 HTML 框架。

4

1 回答 1

1

I suspect there's something dynamic going on, either via javascript, server-side, or in your IDE itself.

See the html snippet working on jsfiddle.net here: http://jsfiddle.net/WUjhu/

In general, though, just because one browser will run it doesn't mean much, because browsers are very tolerant of horribly malformed html, so what you want to do with your html when you encounter a problem is run in through the validator here: http://validator.w3.org/#validate_by_input

Of course, when putting that code through the validator, there are no errors, because it's perfectly valid html, as long as only that html is involved. To me, that implies that your editor/previewer is failing you. Check the doctype and surrounding code to see what it adds that could be breaking stuff, otherwise get a better editor.

于 2012-07-25T16:06:52.350 回答