hl同学慧眼发现了JQuery这个很不错的类库,hl有时间不妨丰富丰富这个东西的咨询
===== 介绍 =====
Jquery是继prototype之后又一个优秀的Javascrīpt框架。有人使用这样的一比喻来比较prototype和jquery:prototype就像Java,而jquery就像ruby.实际上我比较喜欢java(少接触Ruby 罢了)但是jquery的简单的实用的确有相当大的吸引力啊!在项目里我把jquery作为自已唯一的框架类包。使用其间也有一点点心得,其实这些心得,在jquery的文档上面也可能有讲,不过还是记下来,以备忘罢。
http://jquery.com/
===== 笔记 =====
取一个ID元素: $('#username')
用样式取: $('.classname')
取 input 的值: $('#username').val()
给 input 赋值: $('#username').val('kenvin')
取 innerHTML : $('#info_username').html();
赋值: $('#info_username').html("对不起,您的用户不正确");
// ajax post 实例
$.post("register.php?action=checkusername", { username: $('#username').val() },
function(txt) {
if(txt == 'OK' ) {
$('#info_username').html("用户名验证通过");
} else {
$('#info_username').html("错误:" + txt);
}
});
- [[http://15daysofjquery.com/examples/mailto/demo4.php|ajax post实例]] [[http://15daysofjquery.com/examples/contact-forms/code/demo.php|ajax get实例]]
- Jtip 帮助系统 http://www.codylindley.com/blogstuff/js/jtip/
// 让所有表单提交的时候,submit样式里没有no的自动disabled。防止表单重复提交
jQuery(document).ready(function($) {
$("form").submit( function(){ $("input[@type=submit]").not(".no").attr("disabled","disabled"); } );
})
最简洁的ajax:
$('#id').load('ajax.php')
==== ajax:1072896658错误 ====
昨天漫游平台CS系统换服务器,结果今天出现了问题,在火狐下很正常,在IE下出现了不能PK,不能过关等功能,我仔细看了一下,终于找到原因,
这些操作都是ajax操作,显示js错误:系统错误:-1072896658;
出现的原因是:**ajax中XMLHttpRequest对象请求的文档未指定正确的utf-8编码**
之前是好的,可能昨天修改文件时把文件的编码改了,解决办法是把CI的index.php加上:
header("Content-Type: text/plain; charset=utf-8");
===== jquery插件 =====
* jQuery Easing Plugin : 动画效果。 http://gsgd.co.uk/sandbox/jquery/easing/
* 拖拽的模块: http://interface.eyecon.ro/demos/sort.html
* 照片效果 分页 http://benjaminsterling.com/jquery-jqgalscroll-photo-gallery/
* 照片效果 自动切换照片 http://benjaminsterling.com/jquery-jqshuffle/#getting-started
* 照片效果 翻页效果: http://gmarwaha.com/jquery/jcarousellite/index.php
* 动画菜单效果 http://gmarwaha.com/blog/?p=7
* 滚动新闻: http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
* jscroller:可向各个方向滚动 http://jscroller.markusbordihn.de/
* Textgrad 文字颜色渐变/动画渐变效果 http://www.si-les-idees-suffisaient.net/jquery/textgrad.html
* Tabs 标签切换,支持动画效果 http://www.stilbuero.de/jquery/tabs_3/
* Jquery**对话框插件**: http://dev.iceburg.net/jquery/jqModal/
* 光标处插入文本 jquery.caretInsert.js : http://www.zeali.net/entry/561
* jQuery plugin: Accordion jQuery plugin: Autocomplete [[http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/|jQuery plugin: Tooltip]] jQuery plugin: Treeview jQuery plugin: Validation
* 弹出菜单 http://www.wemvc.com/55.html
* 推荐插件列表 http://www.cnblogs.com/terrylee/articles/988623.html
===== 资源列表 =====
* http://docs.jquery.com/Main_Page
* **中文可视化api 最新版**: http://www.shawphy.com/jqueryapi/
* **英文可视化api**:http://visualjquery.com/
* **中文可视化api**: http://jquery.org.cn/visual/cn/index.xml
* http://jquery.bassistance.de/jquery-getting-started.html
* jquery是什么技术? http://www.phpbulo.com/group/a/71
* **推荐: 十五天学会jquery** http://wiki.jquery.org.cn/
* **thickbox** http://jquery.com/demo/thickbox/
* 指南 http://docs.google.com/View?docID=dgh4bdmv_12sx2rh