1.<a>标签-超链接中confirm方法使用介绍

<a href="a.html" onclick="if(confirm('确定删除?')==false)return false;">删除</a>

2.<select>下拉框三级联动效果

1).html代码

<select name="select_element" id="firstServiceType"></select>
<select name="select_element" id="secondServiceType"></select>
<select name="select_element" id="thirdServiceType"></select>

2).JS代码

<script type="text/javascript">

$(document).ready(function () {
$("#code").val();
GetFirstType();
$("#firstServiceType").change(function () { $("#Type").val($(this).val()); GetSecondType() });
$("#secondServiceType").change(function () { $("#Type").val($(this).val()); GetThirdType() });
$("#thirdServiceType").change(function () { $("#Type").val($(this).val()); });
});
function GetFirstType() {
$("#firstServiceType").empty();
$("#firstServiceType").append('<option>请选择</option>');
$.getJSON("/ServiceType/GetFirstType", function (data) {
$.each(data, function (i, item) {
$("<option></option>")
.val(item["Code"])
.text(item["AbbrName"])
.appendTo($("#firstServiceType"));
});
GetSecondType();
});
}
function GetSecondType() {
$("#secondServiceType").empty();
$("#secondServiceType").append('<option value="0">请选择</option>');
var url = "/ServiceType/GetSecondType/?code=" + $("#firstServiceType").val();

$.getJSON(url, function (data) {

$.each(data, function (i, item) {
$("<option></option>")
.val(item["Code"])
.text(item["AbbrName"])
.appendTo($("#secondServiceType"));
});
GetThirdType();
});
}
function GetThirdType() {
$("#thirdServiceType").empty();
$("#thirdServiceType").append('<option value="0">请选择</option>');
var url = "/ServiceType/GetThirdType/?code=" + $("#secondServiceType").val();
$.getJSON(url, function (data) {
$.each(data, function (i, item) {
$("<option></option>")
.val(item["Code"])
.text(item["AbbrName"])
.appendTo($("#thirdServiceType"));
});

});
}
</script>

3.上传图片时预览功能

1).htm代码

<img id="img" style="width:100px; height:100px;" src=""/>

<input type="file" name="pic" id="file" />

2).JS代码

<script type="text/javascript">
$(document).ready(function () {
$("#file").bind("change", function () {
var f = document.getElementById('file').files[0];
var src = window.URL.createObjectURL(f);
$("#img").attr("src", src);

})

});
</script>

项目中常用的JS操作技巧的更多相关文章

  1. 项目中常用的js骚操作

    //打开网址window.open("http://www.runoob.com"); //判断是否为url var url = $("#url").val() ...

  2. 项目中常用git命令操作指令(一般正常的话够用不够再看相关git命令)

    配置git1.首先在本地创建ssh key:ssh-keygen -t rsa -C "github上注册的邮箱" //(一路回车)2.进入c:/Users/xxxx_000/.s ...

  3. 在项目中常用的JS方法封装

    使用方法简单,只需要放在你的 utils.js 工具文件中,直接export const 加上下面封装方法,在别的文件中使用 {方法1,方法2,方法3...}引用后直接使用即可. 01.输入一个值.返 ...

  4. 项目中常用的js方法封装---自留

    1.输入一个值,返回其数据类型 type = para => { return Object.prototype.toString.call(para).slice(8,-1) } 2.冒泡排序 ...

  5. 项目中常用的js方法(持续更新)

    <script> var utils = { //时间戳转日期(timestamp:时间戳 默认当前时间) dateFormat: function(timestamp = new Dat ...

  6. 项目中常用js方法整理common.js

    抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...

  7. Android 项目中常用到的第三方组件

    项目中常用到的第三方组件 1 社会化分享ShareSDK-Core-2.5.9.jarShareSDK-QQ-2.5.9.jarShareSDK-QZone-2.5.9.jarShareSDK-Sin ...

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

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

  9. 项目中常用的MySQL 优化

    本文我们来谈谈项目中常用的MySQL优化方法,共19条,具体如下: 一.EXPLAIN 做MySQL优化,我们要善用EXPLAIN查看SQL执行计划. 下面来个简单的示例,标注(1.2.3.4.5)我 ...

随机推荐

  1. 块级元素、行内元素、display属性

    块级元素 特点: 总是以一个块的形式表现出来,占领一整行.若干同级块元素会从上之下依次排列(使用float属性除外). 可以设置高度.宽度.各个方向的margin以及各个方向的padding. 当宽度 ...

  2. CentOS 下的apache服务器配置与管理

    一.WEB服务器与Apache1.web服务器与网址 2.Apache的历史 3.补充http://www.netcraft.com/可以查看apache服务器的市场占有率同时必须注意的是ngnix, ...

  3. sqlplus导入sql,dmp导入导出

    1.创建表空间及用户名 1).用Oracle的EM做数据库的管理(表空间.用户及授权为例子) https://blog.csdn.net/anderslu/article/details/566701 ...

  4. springMVC List对象转换为json列表对象

    @ResponseBody @RequestMapping("xxx.do") public List<POJO> getList(){ return List< ...

  5. java并发初探CyclicBarrier

    java并发初探CyclicBarrier CyclicBarrier的作用 CyclicBarrier,"循环屏障"的作用就是一系列的线程等待直至达到屏障的"瓶颈点&q ...

  6. java关于hasNext()

    编写一段程序实现如果输入的一组数中含非整数数字,输出数字相加的和以及"attention"字符,如果全部是数字便输出数字的和. 程序1: package mian; import ...

  7. uWSGI, Thread, time.sleep 使用问题

    下面的问题,在flask程序独立运行中,都没有问题,但是部署在 uwsgi 上表现异常: 1. 在http请求处理过程中,产出异步线程,放在线程池中,线程的启动时间有比较明显的延迟. 2. 在异步线程 ...

  8. eclipse中maven web项目部署时缺少classes文件或者resources文件

    写这篇博客的原因 问题描述 昨天发现eclipse中maven web项目部署时缺少classes文件或者resources文件 本来以为是很常见的原因, 依次检查"Java Build P ...

  9. Matplotlib 安装

    章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...

  10. spring bean容器学习

    bean是Spring种最核心的东西 ,如果说Spring是个水桶的话,bean就是桶里面的水,桶里面没有水也就没有意义了. public class MyTestBean { private Str ...