select的option异常的总结
来源:http://www.ido321.com/1189.html
昨天,在项目中碰到了option显示异常的原因,截图如下:
Firefox中用css控制之后效果
chrome和IE中css不奏效
代码:
<div class="controls">
<select name="ksname" id="ksname">
<?php
while (!!$rowDK = fetchAssoc($resultDK))
{
?>
<optgroup label="<?php echo $rowDK['name']; ?>">
<?php
$resultKS = queryDB("select table_dake.id,table_keshi.sid,table_keshi.name from table_dake,table_keshi
where table_dake.name='{$rowDK['name']}' and table_keshi.sid=table_dake.id");
while(!!$rowKS = fetchAssoc($resultKS))
{
?>
<option value ="<?php echo $rowKS['name']; ?>"><?php echo $rowKS['name']; ?></option> <?php
</optgroup>
}
}
free($resultDK);
free($resultKS);
?>
</select>
</div>
调 试了很久,在网上也找了方法,最终无果,只要去请教大牛了。大牛建议我去查看一下源代码,是不是样式改变了?这段代码的select部分没有任何样式,怎 么会多?看了源代码之后,样式的确没有多,但是每个option后面多了一个</optgroup>.又回头看了代码,才明白,我把< /optgroup>写在了内循环中,按照我的逻辑,本应该放在外循环。调整之后,一切正常。
所以,调试代码又get了一招:查看原代码
下一篇:90个IT社区等你来挑!!
select的option异常的总结的更多相关文章
- IE8下JQuery clone 出的select元素使用append添加option异常解决记录
遇到一个怪现象,由于配置参数是多实例的, 故采用JQuery对模板HTML代码进行clone, HTML代码中包括select标签, 在克隆之后需要对select进行添加option. 在firefo ...
- AngularJS下拉列表select在option动态变化之后多出了一个错误项的问题
场景: Select初始化之后,选中select的某个选项 通过AngularJS更新select的选项 错误写法: HTML(使用ng-repeat) <div ng-app="Te ...
- HTML 表单和输入<textarea><label><fieldset><legend><select><optgroup><option><button>
textarea><label><fieldset><legend><select><optgroup><option>& ...
- 有关attribute和property,以及各自对select中option的影响
这个问题老生常谈,但是直到现在我依旧时常会把它搞混.下面列一些各自的特性. attribute property 设置方法 option.setAttribute('selected', true ...
- JS实现选择不同select标签option值的验证
js实现不同select标签option值的验证 功能描述: 选择中文时,匹配中文的正则表达式,选择英文选项是匹配英文的表达式,并且有对应的提示信息. html代码片段: <select id= ...
- jquery动态刷新select的值,后台传过来List<T>,前台解析后填充到select的option中
jquery动态刷新select的值:将后台传来的List<T>赋值到select下的option. 第一个select选择后出发该方法refreshMerchant(params),传递 ...
- js 操作select和option
js 操作select和option 1.动态创建select function createSelect(){ var mySelect = document.createElement_x(&qu ...
- JQuery中对Select的option项的添加、删除、取值
jQuery获取Select选择的Text和Value: $("#select_id").change(function(){//code...}); //为Select添加事件, ...
- [Angular 2] ng-model and ng-for with Select and Option elements
You can use Select and Option elements in combination with ng-for and ng-model to create mini-forms ...
随机推荐
- 快速学习bootstrap前台框架
W3c里的解释 使用bootstrap需要注意事项 1. 在html文件第一行要加上<!doctype html>[s1] 2. 导入bootstrap.min.css文件 3. 导 ...
- python流程控制语句 ifelse - 2
#! /usr/bin/python x = input('please input a integer:') x = int (x) ): print('你输入了一个负数') else: print ...
- Servlet3.0的新特性
注意:Servlet3.0的项目一定要使用Tomcat7.0才能看到效果!! 1.新增标注支持 在Servlet3.0的部署描述文件web.xml的顶层标签<web-app>中有一 ...
- DefaultHashOperations multiget的一个坑
DefaultHashOperations的multiget如果没有数据会返回java.util.Collections.EmptyList,这个List没有重写add方法. List<Long ...
- IOS判断手机型号
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CG ...
- ifdebug
#if DEBUG 首先,大小写不能写错. 其次,解决方案配置设为:Debug,才会执行该语句,如果在条件里面搭配Debug.Assert等,效果甚佳.而如果要设置为Release模式,就不会执行条件 ...
- 加密解密(10)常见HASH算法:MD5(128bit),SHA1(160bit)
- Builder创建者模式
http://www.codeproject.com/Articles/42415/Builder-Design-Pattern In Elizabeth's day care center, the ...
- Android开发之单例模式
参考:http://blog.csdn.net/guolin_blog/article/details/8860649 http://www.cnblogs.com/liyiran/p/5283690 ...
- TC SRM 593 DIV1 250(dfs)
这图最多3色就可以 搜2就行了 #include <iostream> #include<cstdio> #include<cstring> #include< ...