jquery json遍历和动态绑定事件
<div id='tmpselectorList' style='border: 1px solid grey;max-height: 150px;position:absolute;text-align: left; overflow: auto;background:white;width:153px;'>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#engineerName").change(function () {
//ajax获取数据库查询得到的数据
var name = $("#engineerName").val();
if(name != ""){
$.ajax({
type: "get",
dataType: "json",
url:"${contextPath}/carUpload/enginNameByLike/" + name +"?random="+Math.random(),
success: function (result) {
//清空原来的旧数据
$("#tmpselectorList").empty(); var html = "<ul class='ui-menu' style='cursor: pointer;'>"; //json数据遍历
$.each( result.data, function(index,item){
//alert("index:"+index+", item:"+ item);
html += "<li>"+item+"</li>";
}); html += "</ul>";
$("#tmpselectorList").append(html); }
});
}
}); //jquery动态绑定事件
$("#tmpselectorList").on("click","ul li",function(){
//赋予值
$("#engineerName").val( $(this).text() );
}) ;
});
</script>
jquery json遍历和动态绑定事件的更多相关文章
- jQuery json遍历渲染到页面并且拼接html
jQuery 处理 json遍历在页面中显示,并且拼接html. 1 <title>json多维数组遍历渲染</title> 2 3 <body> 4 <di ...
- jQuery的动态绑定事件的应用
注意:bind()的事件绑定是只对当前页面选中的元素有效.如果你想对动态创建的元素bind()事件,是没有办法达到效果的 <script src="jquery-1.11.2.min. ...
- 用jquery给元素动态绑定事件及样式
网页输出的时候,可以用jquery给各种元素绑定事件,或设置样式. 之所以这样做,好处是节省代码,尤其适合元素很多,并且元素的事件对应的函数雷同的情况. 看看以下代码: <div id=&quo ...
- jquery $.each遍历json数组方法
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/ ...
- jquery - 动态绑定事件
举个例子: html页面 <div><button type="button" class="test">测试</button&g ...
- jQuery学习小结1-CSS操作+事件
一.DOM对象和jQuery 对象互换 1.jQuery对象 就是通过jQuery包装DOM对象后产生的对象.jQuery对象是jQuery独有的,其可以使用jQuery里的方法.比如: $(&quo ...
- JQuery + JSON作为前后台数据交换格式实践
JQuery + JSON作为前后台数据交换 JQuery提供良好的异步加载接口AJAX,可以局部更新页面数据, http://api.jquery.com/category/ajax/ JSON作为 ...
- jQuery: jquery.json.js
http://api.jquery.com/jQuery.parseJSON/ http://www.json.org/json-zh.html http://fineui.codeplex.com/ ...
- jQuery三——筛选方法、事件
一.jquery常用筛选方法 以下为jquery的常用筛选方法: 代码示例如下: <!DOCTYPE html> <html lang="en"> < ...
随机推荐
- 条件放在left join后面和where后面
有这样一个查询的差异: 两张表如下: 语句在这里: create table #AA ( ID int, Name nvarchar() ) insert into #AA ,'项目1' union ...
- LN : leetcode 292 Nim Game
lc 292 Nim Game 292 Nim Game You are playing the following Nim Game with your friend: There is a hea ...
- hdu 5412 CRB and Queries
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5412 CRB and Queries Description There are $N$ boys i ...
- bzoj 3223/tyvj 1729 文艺平衡树 splay tree
原题链接:http://www.tyvj.cn/p/1729 这道题以前用c语言写的splay tree水过了.. 现在接触了c++重写一遍... 只涉及区间翻转,由于没有删除操作故不带垃圾回收,具体 ...
- JavaScript高级程序设计之Date类型
ECMAScript 中的 Date 类型是在早期 Java 的 java.util.Date 类基础上构建的. Date 类型使用自 UTC (国际协调时间)1970年1月1日午夜(零时)开始经过的 ...
- golang没有条件表达式?:
详见The Go Programming Language Specification中Expressions一章中未提及此表达式, 故其不支持. 再强调一次, GO不支持条件表达式 conditio ...
- java数据结构和算法------顺序查找
package iYou.neugle.search; public class Sequence_search { public static int SequenceSearch(double[] ...
- C++实现禁忌搜索解决TSP问题
C++实现禁忌搜索解决TSP问题 使用的搜索方法是Tabu Search(禁忌搜索) 程序设计 1) 文件读入坐标点计算距离矩阵/读入距离矩阵 for(int i = 0; i < CityNu ...
- [转]反向代理过程与Nginx特点详解
原文链接:<Nginx搭建反向代理服务器过程详解> 1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内 ...
- graphicsMagick 文档
ImageMagick资料 ---------------------------------------------------------------------------- ImageMagi ...