当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 用jquery来定位

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 用jquery来定位


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 448 ::
收藏到网摘: n/a

demo:http://www.healdream.com/upLoad/html/jquery/position/
down:http://www.51files.com/?Z25US63TM6OBHQJ2XM58
用法:
首先当然是将两个js包含进来了
复制代码 代码如下:

<script type="text/javascript" src="../jquery.js"></script>
<!-- load dimensions.js (this is what we're testing! -->
<script type="text/javascript" src="dimensions.js"></script>

复制代码 代码如下:

<script type="text/javascript" charset="utf-8">
$(function() {//这个是$(document).ready()的简写
$('#userAgent').html(navigator.userAgent);//.html(str)方法是将当前dom用str替代
//navigator.userAgent这句是用来得到客户端的浏览器类型的
$('a').click(function(event) {//对链接的点击事件定义函数
var href = this.href;//得到当前的链接字符串
var id = href.substr(href.indexOf('#'));//得到#后面的字符串
var options = {//定义各个参数,主要是待会move时用到
margin: parseInt( $('#margin').val() ),//.val()方法是得到当前对象的value值
border: parseInt( $('#border').val() ),//parseInt方法就是转换为int型,也就是整形
padding: parseInt( $('#padding').val() ),
scroll: parseInt( $('#scroll').val() )
};
var offset = {};
//offset方法是在dimensions.js里定义的
$(id).offset(options, offset);
$('#moveable').css(offset);//设置id为moveable的dom的css为offset
return false;
});
});
</script>

主要的代码就这些了,是不是很简单啊