js+jquery
改变元素的不透明度
<!DOCTYPE html>
<html>
<head>
<script>
function ChangeOpacity(x)
{
// 返回被选选项的文本
var opacity=x.options[x.selectedIndex].text;
var el=document.getElementById("p1");
if (el.style.opacity!==undefined)
{el.style.opacity=opacity;}
else
{alert("Your browser doesn't support this example!");}
}
</script>
</head>
<body> <p id="p1">请从下面的例子中选择一个值,以改变此元素的不透明度。</p>
<select onchange="ChangeOpacity(this);" size="5">
<option />0
<option />0.2
<option />0.5
<option />0.8
<option selected="selected" />1
</select> </body>
</html>
根据DIV内容 怎么得到DIV的ID
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="ec/jquery/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function test(only) {
var $objs = $("div[id]:contains('德国')");
var arr = [];
$objs.each(function () {
if (only && $(this).text().length > )
return false;
arr.push($(this).attr("id"));
});
alert(arr);
}
</script>
</head>
<body>
<div id="code1">中国</div>
<div id="adeg">美国</div>
<div id="dg3g">英国</div>
<div id="gjr4">德国</div>
<div id="bkjt">法国</div>
<div id="Div1">德国1</div>
<div id="Div2">德国2</div>
<div id="Div3">德国3</div>
<div id="Div4">德国4</div>
<input type="button" value="取得包含德国的 div 的id" onclick="test(false)" />
<input type="button" value="取得只包含德国的 div 的id" onclick="test(true)" />
</body>
</html>
each :
$("div").each(function() {
if($(this).html()=="德国"){alert($(this).attr("id"))}
});
$("div:contains('德国')").eq(0).attr("id");
创建数组对象
创建 Array 对象的语法: new Array();
new Array(size);
new Array(element0, element1, ..., elementn);
for in
var x
var mycars = new Array()
mycars[] = "Saab"
mycars[] = "Volvo"
mycars[] = "BMW" for (x in mycars)
{
document.write(mycars[x] + "<br />")
}
合并两个数组
var arr = new Array()
arr[] = "George"
arr[] = "John"
arr[] = "Thomas" var arr2 = new Array()
arr2[] = "James"
arr2[] = "Adrew"
arr2[] = "Martin" document.write(arr.concat(arr2))
用数组元素组成字符串join
var arr = new Array();
arr[] = "George"
arr[] = "John"
arr[] = "Thomas" document.write(arr.join()); document.write("<br />"); document.write(arr.join(".")); 输出结果: George,John,Thomas
George.John.Thomas
数组排序 sort
document.write(arr.sort()) <script type="text/javascript"> function sortNumber(a, b)
{
return a - b
} var arr = new Array()
arr[] = ""
arr[] = ""
arr[] = ""
arr[] = ""
arr[] = ""
arr[] = "" document.write(arr + "<br />")
document.write(arr.sort(sortNumber)) </script>
,,,,,
,,,,,
随机整数
下面的例子使用了 Math 对象的 floor() 方法和 random() 来返回一个介于 和 之间的随机数: document.write(Math.floor(Math.random()*))
js+jquery的更多相关文章
- js,jquery,css,html5特效
包含js,jquery,css,html5特效,源代码 本文地址:http://www.cnblogs.com/roucheng/p/texiao.html 2017新年快乐特效 jQuery最新最全 ...
- Js/Jquery获取iframe中的元素
转载: Js/Jquery获取iframe中的元素 - - ITeye技术网站http://java-my-life.iteye.com/blog/1275205 在web开发中,经常会用到ifram ...
- js/jquery/html前端开发常用到代码片段
1.IE条件注释 条件注释简介 IE中的条件注释(Conditional comments)对IE的版本和IE非IE有优秀的区分能力,是WEB设计中常用的hack方法.条件注释只能用于IE5以上,IE ...
- js jquery 页面加载初始化方法
js jquery 页面加载初始化方法 一.js页面加载初始化方法 // 1.在body里面写初始化方法. <body onload='init()'> </body> < ...
- js jquery 选择器总结
js jquery 选择器总结 一.原始JS选择器. id选择器:document.getElementById("test"); name选择器:document.getElem ...
- [JS]jQuery,javascript获得网页的高度和宽度
[JS]jQuery,javascript获得网页的高度和宽度网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeigh ...
- spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js...
问题:spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js... web.x ...
- js jquery中 的数据类型
任何一门语言, buguan 是动态的, 还是像C语言的, 都有严格的 类型 "概念的", 这个是由于 编译器和解释器要求的, 需要的. 所以在是使用像 js, jquey ,ph ...
- paip.提升效率--数据绑定到table原理和流程Angular js jquery实现
paip.提升效率--数据绑定到table原理和流程Angular js jquery实现 html #--keyword 1 #---原理和流程 1 #----jq实现的代码 1 #-----An ...
- JS Jquery去除数组重复元素
js jquery去除数组中的重复元素 第一种:$.unique() 第二种: for(var i = 0,len = totalArray_line.length;i < len;i++) { ...
随机推荐
- Homebrew 的安装方法(官方的方法老师安装失败) 第三方
官网:http://brew.sh/index_zh-cn.html 安装方式见 官网,在shell里执行如下语句,如下:ruby -e "$(curl -fsSL https://raw. ...
- ssh加密公私钥
SSH公钥登录原理 在平时工作中我们经常要远程登录服务器,这就要用到SSH协议: $ ssh user@host 主要有两种登录方式:第一种为密码口令登录,第二种为公钥登录 密码口令登录 通过密码进行 ...
- epel源报错怎么解决?
http://mirrors.aliyun.com/centos/6/extras/x86_64/repodata/81fdefdd048c01dcc6cda1fd53aacec2a0613ea10d ...
- easyui中datagrid用法,加载table数据与标题
加载标题写法: 多行标题:columns: [[ columns: [[ { field: 'itemid', title: 'Item ID', rows ...
- php 不依赖数据实现删除图片,核心代码
<?php $file = "ueditor\php\upload\image\*\*.png"; foreach (glob("$file") as $ ...
- imx6 i2c分析
本文主要分析: 1. i2c设备注册 2. i2c驱动注册 3. 上层调用过程参考: http://www.cnblogs.com/helloworldtoyou/p/5126618.html 1. ...
- perl chomp 函数的真正作用
之前一直以为chomp函数只是去掉字符串末尾的\n, 但是今天写程序遇到一个bug,最后的原因就处在chomp上: 读取fasta文件,内容如下: >1 ATGCTAGCTACGTACGTACG ...
- CentOS查看你是否有USB 3.0端口
近来的大多数的新计算机都有了USB 3.0接口了.但是你怎么知道你的计算机有没有USB 3.0接口?这篇短文中,我们会告诉如何在Linux下知道你的系统上有USB 3还是USB3接口. 在Linux终 ...
- (转)Spring开启Annotation<context:annotation-config> 和 <context:component-scan>诠释及区别
转自:https://www.cnblogs.com/leiOOlei/p/3713989.html <context:annotation-config> 和 <context:c ...
- ScSR超分辨率的效果