1.点击获得当前元素索引,实现切换相应的图片路径

$(".li").bind("click", function () {
var _num = $(this).index();//或者 var _num = $(".li").index($(this));
$(".pic_poster_img img").attr("src", "images/live/mews_pic" + (_num + 1) + ".jpg");
});

2.窗口改变时调整元素宽度

$(function () {
//页面加载执行宽度微调
TextWidthResponsive();
//窗口改变执行宽度微调
$(window).resize(function () {
TextWidthResponsive();
});
});
function TextWidthResponsive() {
var _width = $(window).width() - 1050;
$(".focus_title_box").width(_width);
}

3.手机号码验证

var _phone = $(".phone").val();
_name = $.trim(_name);
_phone = $.trim(_phone); if (_name == "") { alert("请输入姓名!");
return;
} if (_phone == "") {
alert("请输入联系方式!");
return;
} var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$//; if (!(reg.test(_phone))) {
alert('对不起,您输入的手机号码错误。');
return;
}

4.对移动端动态填充的元素绑定点击事件

 //选择答案
$("body").undelegate("touchstart").delegate(".option", "touchstart", function (e) {
$(".option").removeClass("hover");
$(this).addClass("hover"); });

  

常用jQuery代码01的更多相关文章

  1. 常用jQuery代码

    返回元素的html包括它本身 <div class="test"><p>hello,你好!</p></div> <script ...

  2. 常用jQuery代码03

    1.查看浏览器信息 navigator.userAgent 检索浏览器信息包括哪些字符 例如: if (navigator.userAgent.toLowerCase().indexOf(" ...

  3. 常用jQuery代码02

    一.each函数拿到每个元素的宽度 setTimeout(function () { $(".sticker_list img").each(function () { var W ...

  4. js/jquery/html前端开发常用到代码片段

    1.IE条件注释 条件注释简介 IE中的条件注释(Conditional comments)对IE的版本和IE非IE有优秀的区分能力,是WEB设计中常用的hack方法.条件注释只能用于IE5以上,IE ...

  5. 十五个常用的jquery代码段【转】

    好的文章顶一个 回到顶部按钮 通过使用 jQuery 中的 animate 和 scrollTop 方法,你无需插件便可创建一个简单地回到顶部动画: 1 // Back to top 2 $('a.t ...

  6. 十五个常用的jquery代码段

    十五个常用的jquery代码段 回到顶部按钮 通过使用 jQuery 中的 animate 和 scrollTop 方法,你无需插件便可创建一个简单地回到顶部动画: 1 // Back to top ...

  7. 记录下项目中常用到的JavaScript/JQuery代码二(大量实例)

    记录下项目中常用到的JavaScript/JQuery代码一(大量实例) 1.input输入框监听变化 <input type="text" style="widt ...

  8. 最实用、最常用的jQuery代码片段

    // chinacoder.cn JavaScript Document $(document).ready(function() { //.filter(":not(:has(.selec ...

  9. !!!常用JS代码块 (jquery)

    jquery代码块 <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> ...

随机推荐

  1. ural 1153. Supercomputer

    1153. Supercomputer Time limit: 2.0 secondMemory limit: 64 MB To check the speed of JCN Corporation ...

  2. codeforces round #201 Div2 A. Difference Row

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

  3. TYVJ P1073 加分二叉树 Label:区间dp

    背景 NOIP2003 提高组 第三道 描述 设一个n个节点的二叉树tree的中序遍历为(l,2,3,…,n),其中数字1,2,3,…,n为节点编号.每个节点都有一个分数(均为正整数),记第j个节点的 ...

  4. JavaScript基础知识总结

    正则表达式: 是一种专门用于操作字符串规则. 正则表达式: 通过一些符号来表达,简化对字符串的复杂操作. 弊端:阅读性较差 常见操作: 1.匹配 String matches(regex) 2.获取( ...

  5. FFmpeg - 音频解码过程

    1. 注册所有解码器 av_register_all(); 2. Codec & CodecContext AVCodec* codec = avcodec_find_decoder(CODE ...

  6. 【转】delphi程序只允许运行一个实例的三种方法:

    一.        创建互斥对象 在工程project1.dpr中创建互斥对象 Program project1 Uses Windows,Form, FrmMain in 'FrmMain.pas' ...

  7. 通过get方式传递参数

    就一个图吧

  8. 使用CSS3实现百叶窗

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

  9. 【iHMI43 4.3寸液晶模块】demo例程(版本1.02)发布

    ============================== 技术论坛:http://www.eeschool.org 博客地址:http://xiaomagee.cnblogs.com 官方网店:h ...

  10. php连接redis数据库 操作redis任务队列

    首先你的安装phpredis扩展在你的服务器上 $redis = new Redis(); $redis->connect('119.29.10.xx',6379); $redis->au ...