javascript - 如何正确地将选择标签放入表格单元格

标签 javascript jquery html css dom

我拼命地尝试让一个选择标签适合表格单元格,就像它属于那里一样,而不是像有人用 pry 棍把它塞进去一样。这是代码,后面是它如何显示的图片:

<tr>
  <td class="lblCell_L" >ISIN Code </td>
  <td id="ISINcb" class="lblCell_R" align="center">
   <select id='isinz' width="144" style="height:19px; width:140px; text-align:center;">
       <option id="ISIN1" onclick="JavaScript:quarterUpdate()" >A</option>
       <option id="ISIN2" onclick="JavaScript:quarterUpdate()" >B</option>
       <option id="ISIN3" onclick="JavaScript:quarterUpdate()" >C</option>
       <option id="ISIN4" onclick="JavaScript:quarterUpdate()" >E</option>
   </select>
  </td>
  <td class="lblCell_tx" id="isinOptions" style="color:#a56;">0</td>
</tr>

这在 FireFox 中出现的方式:

Select Tag has its own border inside the cell borders

所以,这真的很难看,因为 Select 对象在单元格内有自己的可见边框,单元格有自己的边框。就像把 pig 肉塞进鹅里一样......看起来很惨淡!

是否可以抑制表格单元格边框以允许选择标签边框取代它们?

您可能还会注意到,该单元格的高度高于其他“纯文本”单元格。

最佳答案

播放选择的边框(这在 Safari 中可能有效,也可能无效)

select {
    border: 0;
    width: 100%;
}

这是一个 JsFiddle:http://jsfiddle.net/EuNw4/

也可以使用 select onchange"JavaScript:quarterUpdate()" 而不是很多 option onclick="JavaScript:quarterUpdate()"... Inline不应使用这样的 Javascript,您应该这样做:

// jQuery
jQuery(document).ready(function($) {
    $('#isinz').on('change', quarterUpdate());
});

关于javascript - 如何正确地将选择标签放入表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15978632/

相关文章:

jquery - 颜色选择器不添加到动态 HTML 表

javascript - 如何使用箭头键和悬停事件将 css 应用于下拉表中的链接?

jquery - 带有滑动动画的 Bootstrap 水平下拉菜单

javascript - Jquery按钮点击事件不触发

html - 打印媒体查询在 Chrome 中被忽略?

javascript - jQuery 使用 src 选择 img

javascript - 正则表达式匹配字符串格式为 @ 或 # 后跟点分隔的字符串,不包含空格

html - 我可以使用 mailto :? 设置电子邮件的主题/内容吗

javascript - 动态替换ios项目中的.h和.m文件(bundle路径)

javascript - 在 Angular ng-repeat 中使用现有的 JS 函数