jQuery常用代码片段】的更多相关文章

1. 禁止右键点击 ? 1 2 3 4 5 $(document).ready(function(){     $(document).bind("contextmenu",function(e){             return false;     }); }); 2. 隐藏搜索文本框文字 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hide when clicked in the search field, the value.(exampl…
检测IE浏览器 在进行CSS设计时,IE浏览器对开发者及设计师而言无疑是个麻烦.尽管IE6的黑暗时代已经过去,IE浏览器家族的人气亦在不断下滑,但我们仍然有必要对其进行检测.当然,以下片段亦可用于检测其它浏览器. $(document).ready(function() { if (navigator.userAgent.match(/msie/i) ){ alert('I am an old fashioned Internet Explorer'); } }); 平滑滚动至页面顶部 以下是j…
1. 如何修改jquery默认编码(例如默认GB2312改成 UTF-8 ) 1 2 3 4 5 $.ajaxSetup({     ajaxSettings : {         contentType : "application/x-www-form-urlencoded;chartset=UTF-8"     } }); 2. jquery判断元素上是否绑定了事件 1 2 3 4 5 //jQuery event封装支持判断元素上是否绑定了事件,此方法只适用于jQuery绑定…
以下是从visual studio中整理出来的常用代码片段,以作备忘 快捷键: eh 用途: 类中事件实现函数模板 private void MyMethod(object sender, EventArgs e) { throw new NotImplementedException(); } 快捷键: xmethod 有4个 用途: 类中公有静态方法的函数模板 public static void MyMethod(this object value) { throw new NotImpl…
//36个Android开发常用代码片段 //拨打电话 public static void call(Context context, String phoneNumber) { context.startActivity( new Intent(Intent.ACTION_CALL, Uri.parse( "tel:" + phoneNumber))); } //跳转至拨号界面 public static void callDial(Context context, String…
1.jQuery,JS实现tab切换 原生JS实现 HTML代码如下: <div class="wrap"> <ul id="tag"> <li class="current" >标签一</li> <li>标签二</li> <li>标签三</li> </ul> <div id="tagContent"> &l…
Vue3 Snippets for Visual Studio Code Vue3 Snippets源码 Vue3 Snippets下载 This extension adds Vue3 Code Snippets into Visual Studio Code. 这个插件基于最新的 Vue3 的 API 添加了 Code Snippets. Snippets / 代码片段 Including most of the API of Vue3. You can type reactive, cho…
转自:未找到 以下是jquery中比较常用的一些操作实现方式: $("标签名") //取html元素 document.getElementsByTagName("")  $("#ID") //取单个控件document.getElementById("")  $("div #ID") //取某个控件中 控件  $("#ID #ID") // 通过控件ID取其中的控件  $("…
一.预加载图像 如果你的网页中需要使用大量初始不可见的(例如,悬停的)图像,那么可以预加载这些图像. function preloadImages(){ for(var i=0;i<arguments.length;i++){ $("<img>").attr('arc',arguments[i]) } } preloadImages() 二.检查图像是否加载 有时为了继续脚本,你可能需要检查图像是否全部加载完毕. $('img').load(function(){ c…
引言 最近写代码突然有"一把梭"的感觉, 不管三七二十一先弄上再说. 换别人的说法, 这应该是属于"做项目"风格法吧. 至于知识体系, 可以参考官方或者更权威的文档吧. 这里按照使用, 在这个理解阶段记录下代码, 供参考. 适当做一些拓展, 应该比较适合特定阶段的感悟. 如果难懂, 可能还没用到过. 心得这东西跟武学一个道理, 一层有一层的见识. 如果完整, 百科全书式, 官方文档 , 牛人解读体系最靠谱. 此处, 一把梭演示法, 用起来再说. 正文 TreePan…
a.html <div> <button class="button" >点我达</button> </div> b.html <html> <head> <script type="text/javascript" src="./js/jquery-1.0.1.js"></script> <meta http-equiv="Conte…
获取<input />的value $("#id").val( ); 标签间的html $("#id").html('<tr><td>aaa</td> </tr>'); 隐藏/显示 $("#id").show(); $("#id").hide(); 去字符串的前后空格 $.trim(str); ID=con标签内的html的追加 $("#con")…
持续更新中: (1)按照降序查询: List<Entity> entities= Entity.find("order by id desc").fetch(2);   (2)错误验证:   if (validation.hasErrors()) { renderText(validation.errors().get(0).message()); }   (3)是否成功持久化到数据库   if (entity.isPersistent()) {   renderText(…
拨打电话 public static void call(Context context, String phoneNumber) { context.startActivity( new Intent(Intent.ACTION_CALL, Uri.parse( "tel:" + phoneNumber))); } 跳转至拨号界面 public static void callDial(Context context, String phoneNumber) { context.st…
1. 选择或者不选页面上全部复选框 var tog = false; // or true if they are checked on load $('a').click(function() { $("input[type=checkbox]").attr("checked",!tog); tog = !tog; }); 2. 取得鼠标的X和Y坐标 $(document).mousemove(function(e){ $(document).ready(func…
1.获取某天后几天的日期 //d为传入的日期 days为d后面的几天function getAfterDate(d,days){ var dd = new Date(d); dd.setDate(dd.getDate()+days); var y = dd.getFullYear(); var m = dd.getMonth()+1; var d = dd.getDate(); return y+"-"+m+"-"+d;}alert(getAfterDate('20…
1.打开设置(File -> Settings) 2.如图 3 . 最后,在PHP文件中输入 ll 并按 TAB 即可打出代码块…
目录 Python3常用 文件处理 json处理 log日志 argparse使用 INIparser Python3常用 文件处理 class BaseMethod: @staticmethod def run_cmd(cmd): print_log("RUN CMD: %s" %cmd) retcode, output = subprocess.getstatusoutput(cmd) return retcode, output @staticmethod def write_f…
/** * 批量替换方法,批量过滤特殊字符,通常用在通过后的各种编辑器添加的内容在App上编辑上使用 * james.wang 2016-11-11 * 使用方法:ReCont(Content,["<br>", "<br/>", "<p>", "</p>"]) * @param {Object} strCont 要替换的内容 * @param {Object} array 内容里…
1.把所有带有#的空链接换成不友情的链接 $('a[href="#"]').each(function() { $(this).attr('href', 'javascript:void(0)') }); 2.jQuery全选与取消全选插件 (function($){ $.fn.checkall = function(options){ var defaults = {chname:"checkname[]", callback:null}, options = $…
// 绑定事件 cell.privacySwitch.addTarget(self, action: #selector(RSMeSettingPrivacyViewController.switchTapped(_:)), for: UIControl.Event.valueChanged) @objc func switchTapped(_ sender: UISwitch) { print(sender.isOn) } // 跳转页面 var targetVc: UIViewControl…
页面重定位: window.location.replace("http://www.bczs.net"); window.location.href = "http://www.bczs.net"; $(location).attr('href', 'http://www.bczs.net'); $(window).attr('location', 'http://www.bczs.net'); 页面强制刷新当前页: window.location.reload(…
一.从控制台读取东西代码片断: using System; class TestReadConsole { public static void Main() { Console.Write(Enter your name:); string strName = Console.ReadLine(); Console.WriteLine( Hi + strName); } } 二.读文件代码片断: using System; using System.IO; public class TestR…
1.获取屏幕尺寸 document.documentElement.scrollWidth; document.documentElement.scrollHeight; $(window).width(); $(window).height(); 2.页面加载完成执行代码块及DOM加载完毕之后执行 $(document).ready(function(){ //脚本 }); $().ready(function() { //脚本 }) $(function() { //脚本 }) 3.页面分辨…
一:AsyncTask 的使用 (1)activity_main.xml <TextView android:id="@+id/tvInfo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <ProgressBar android:la…
自动创建目录(多级) 相比起使用递归创建,调用 sheljsl 模块简单得多 const shell = require('shelljs') const fs = require('fs') if (!fs.existsSync(dir)) { shell.mkdir('-p', dir) } 自动创建目录函数 /** * 创建文件,自动创建目录 */ function createFile(newPath, txt) { var dir = require('path').dirname(n…
文件名字中含有特殊字符转成空格,因为?‘’等作为文件名是非法的.以下正则表达式进行过滤转换 newname = re.sub("[\s+\.\!\/_,$%^*(+\"\')]+|[+——()?[]“”!,.?.~@#¥%……&*()]",' ', name)…
/** * * @desc 判断两个数组是否相等 * @param {Array} arr1 * @param {Array} arr2 * @return {Boolean} */ function arrayEqual(arr1, arr2) { // 首先要判断是否是数组,传进来的非数组,返回false if(!(arr1 instanceof Array) || !(arr2 instanceof Array)) { return false; } if (arr1 === arr2)…
请求模块: var express = require('express'); var router = express.Router(); // 拿到express框架的路由 var mongoose = require('mongoose'); var Goods = require('../models/goods'); 创建Schema: // 定义一个Schema var orderSchema = new Schema({ 'orderId':String, 'orderState'…
1.选择器 1.根据标签名: $('p')  选择文档中的所有段落    2. 根据ID: $("#some-id")    3.类: $('.some-class') $('.tab curr').removeClass("curr");. $('tr:odd').addClass('odd'); //过滤选择结果集中的奇数元素    $('tr:even').addClass('even'); //过滤选择结果集中的偶数元素 2.this onclick=&qu…