python内部执行过程
2016-01-22 17:51
405 查看
看网上很多动态的下拉菜单,都是用的div实现。
我这个是对select进行更改,更简单一些。
html文件
js文件
我这个是对select进行更改,更简单一些。
html文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script type="text/javascript" charset="utf-8" src="jquery.js"></script> </head> <body> <div> <select id="input1" name="input1" type="text" style="width:100px" ></select> </div> </body> <script type="text/javascript"> $("#input1").focus(function(){ //$("#input1").empty(); //看是否有选项,有则不加载 if(this.options.length>0) return ; //加载动态数据,这里直接用js文件,里面是个json数据,可以从后台得到 $.getJSON("xin.js",function(data){ $.each(data.items,function(i,item){ $("<option value='"+item.dm+"'>"+item.mc+"</option>").appendTo("#input1"); }); }); }); </script> </html>
js文件
{"items":[{"dm":"1","mc":"werwe"},{"dm":"2","mc":"122"}]}
相关文章推荐
- 《python》学习笔记(Day5),继承类
- Python中正则表达式的使用
- 读取含中文字符的txt文档python代码
- python 学习笔记6
- python爬虫入门
- 【python】时间性能分析
- python装饰器
- Python特殊语法:filter、map、reduce、lambda
- Python学习之--函数
- Python中Numpy的tile函数用法以及operator.itemgetter函数和sorted函数
- Simple Digit Recognition OCR in OpenCV-Python
- 均匀分布构造离散型随机变量(以泊松分布为例)python
- Python 爬虫入门(一)
- Python程序员都会喜欢的6个库
- python有哪些好的学习资料或者博客
- python中查看变量内存地址的方法
- python 学习笔记5
- 《Python核心编程》第11章 习题
- 关于virtualenv,python环境引用,pycharm相关配置的使用讨论
- python dict 方法