Category Archives: jquery

jQuery中setTimeout的几种使用方法

jQuery 中 setTimeout/setInterval 不能像在原生态 javascript 中那样使用, 否则会报错. 我们通过例子来说明一下jQuery中setTimeout的几种使用方法, 首先准备好测试用的DIV和公共函数: <div id="div_debug"></div> <script src="http://www.studyday.net/demo/jquery.js"></script> <script language="JavaScript"> function log(s){ $('#div_debug').append(s+'<br>'); } //下文中测试用的代码可以放在这一行注释的下面,替换掉 //... //... </script> 原生态 javascript 中的 setTimeout 基本用法是像这样子的. //原生态 javascript 中的 setTimeout 基本用法 function funA(){ log('funA...'); setTimeout('funA()', 1000); } funA(); 下面是jQuery中setTimeout的几种使用方法. 在线实例 //jQuery 中的用法 function funA(){ log('funA...'); setTimeout('funA()', 1000); } jQuery(document).ready(function($){ //用法1 : 把要调用的函数写在ready外面,使它成为全局函数 funA(); [...]
Also posted in JavaScritp, html | Tagged , , | 2 Comments

常用的 jQuery 插件

自己整理的一些常用的 jQuery 的插件: http://www.malsup.com/jquery/ [对话框插件/推荐] http://dev.iceburg.net/jquery/jqModal/ [对话框插件] http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ [日历插件] http://jquery.bassistance.de/validate/demo/ [表单验证] http://jquery.com/demo/thickbox/ [图片层/对话框] http://demos.flesler.com/jquery/scrollTo/ [锚点特效] http://15daysofjquery.com/examples/jqueryEditInPlace/demo.php [div编辑] http://www.davehauenstein.com/code/jquery-edit-in-place/example/ [div编辑&保存] http://www.appelsiini.net/projects/jeditable/default.html [div编辑&保存] http://www.jdempster.com/category/jquery/disableTextSelect/ [禁止鼠标选取] http://www.phpletter.com/contents/ajaximageeditor/ajax_image_editor.php [图片放大缩小/加图解] http://www.phpletter.com/Demo/Jquery-Floating-Box-Plugin/ [页面四角浮停DIV] http://www.visual-blast.com/javascript/jcrop-jquery-image-crop-plugin/ [图片裁切] http://stanlemon.net/projects/jgrowl.html [类似 163 BLOG右上角提示信息插件] http://jquery.lukelutman.com/plugins/flash/ [Flash IE7 无虚框插件]
Also posted in JavaScritp, html | Tagged | Leave a comment

自动设置DIV字体大小填充DIV

在线演示 <script src="http://www.studyday.net/demo/jquery.js"></script> <script language="JavaScript"> jQuery(document).ready(function($){ $("#txt_input").keyup(function (){ main(); }).keydown(function (){ main(); }).change(function (){ main(); }); function main(){ var loopFlag = true; var divContentHeight = parseInt($("#div_content").css("height")); var htmlCode = $("#txt_input").val()+"<div id='div_mark' name='div_mark'></div>"; $("#div_content").html(htmlCode); var fontSize = get_div_font_size(); while (loopFlag){ loopFlag = get_div_height()>divContentHeight ? true : false; if (loopFlag) { fontSize = fontSize-1; set_div_font_size(fontSize); } } [...]
Also posted in JavaScritp | Tagged | Leave a comment