jQuery笔记

1>jQuery获取value值
<script type="text/javascript">   
$(document).ready(function(){
$("p").append(
  "<b>Single:</b> "   + $("#single").val() +
  " <b>Multiple:</b> " + $("#multiple").val().join(", ")
); 
}); 
</script>

2>jQuery快数隐藏表格(特效)
<script type="text/javascript">
  $(document).ready(function(){	
	$("#table").hide("fast",function(){
		alert("Animation Done!");
	}); 
});
</script>

3>jQuery + ajax + json 获取HTML内容 POST提交模式
<script type="text/javascript">
$(document).ready(function(){
	$('#btnAjax').click(function(){
		$.ajax({
			type:"post",
			url:"json.html",
			success:function(msg){
				var oldvalue = $('#div1').html() + '</br>';
				$('#div1').html(oldvalue + msg);
			}
		});
	});
})
</script>

4>jQuery 获取HTML 标签里面的内容
<script type="text/javascript">
$(document).ready(function(){
		$('#div1').html();
    $('#div1').html("123");
})
</script>

5>jQuery 设置CSS样式, 相当于innerHTML
<script type="text/javasript">
	function sure() {
		var val = "#" + $("#txt").val();
		$(document.body).css( "background", val);
  }		
</script>

6>JS打开自定义对话框
urlPath : 对应页面url
isModelessDialog : 对话框标识
windowName : 未知
width : 宽度
height : 高度
windowProperty ; 对话框参数信息

function getDialog(urlPath, isModelessDialog, windowName, width, height, windowProperty){
	if(urlPath == undefined) {
		return null;	
	}
	if(isModelessDialog == undefined) {
		isModelessDialog = "0";	
	}
	if(windowName == undefined) {
		windowName = "myAnonymousWindow";	
	}
	if(width == undefined) {
		width = "700";	
	}
	if(height == undefined) {
		height = "500";	
	}
	var xposition = 0; 
	var yposition = 0;
	if ((parseInt(navigator.appVersion) >= 4 )) {
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	if(windowProperty == undefined) {
		if(isModelessDialog == "1") {
			windowProperty= "width=" + width + "," 
			+ "height=" + height + "," 
			+ "location=0," 
			+ "menubar=0,"
			+ "resizable=1,"
			+ "scrollbars=1,"
			+ "status=0," 
			+ "titlebar=0,"
			+ "toolbar=0,"
			+ "hotkeys=0,"
			+ "screenx=" + xposition + "," //Netscape  浏览器
			+ "screeny=" + yposition + "," //Netscape  浏览器
			+ "left=" + xposition + "," //IE浏览器     设置对话框距离左边的距离  
			+ "top=" + yposition; //IE浏览器 	        设置对话框距离顶部的距离
		} else {
			windowProperty = 'dialogHeight=' + height + 'px;dialogWidth=' + width + 'px;';
		}
	}
	if(isModelessDialog == "1") {
		window.open( urlPath,windowName,windowProperty );
		return new Object();
	} else {
		var returnObj = window.showModalDialog(urlPath,windowName,windowProperty);
		if(returnObj != undefined) {
			return returnObj;	
		} else {
			return new Object();	
		}
	}
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值