js简单显示和隐藏div,触发超链接,动态更改button值,setInterval()简单使用,jquery easyui弹出框简单使用

js简单显示和隐藏div:

myjs.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	window.οnlοad=function(){
		document.getElementById("hi1").onclick = function(){
			document.getElementById("d").style.display='block';
		};
		document.getElementById("hi2").onclick = function(){
			document.getElementById("d").style.display='none';
		};
	}
</script>
<style type="text/css">
	#d{
		display: none;
		color: red;
	}
</style>
</head>
<body>
		显示<input id="hi1" type="radio" name="hi"/>隐藏<input id="hi2" type="radio" name="hi"/>
		<div id="d">这是要显示和隐藏的数据</div>
</body>
</html>


js触发超链接

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<input type="button" id="button" value="控制超链接" οnclick="fun()"/>
<a href="myjs.html" id="aa">跳转到</a>
</body>
<script type="text/javascript">
	function fun(){
		var link = document.getElementById("aa").href;
		window.location.href = link;
	}
</script>
</html>

隐藏显示div,动态更改button值

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
	#hi{
		display: none;
	}
</style>
<script type="text/javascript">
	window.οnlοad=function(){
		var i=0;
		document.getElementById("bu").οnclick=function(){
			if(i%2==0){
				document.getElementById("bu").value="Click to hidden answer";
				document.getElementById("hi").style.display = 'block';
			}else{
				document.getElementById("bu").value="Click to see the answer";
				document.getElementById("hi").style.display = 'none';
			}
			i++;
		};
	};
</script>
</head>
<body>
<input type="button" id="bu" value="Click to see the answer"/>
<div id="hi">
	This is the answer.
</div>
</body>
</html>

setInterval()

 <html> 
 <head>
 <script>
 var ret = window.setInterval("changeTime()",50);//第二个参数以毫秒为单位
	function changeTime(){
	var d = new Date();
		document.getElementById("changeTime").value=d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日  "+d.getHours()+"时"+d.getMinutes()+"分"+d.getSeconds()+"秒";
	}
	
 </script>
 </head>
 <body> 
<input type="text" id="changeTime" size="30"/>
</body> 
</html> 

jQuery easyui 弹出框

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>ComboBox Actions - jQuery EasyUI Demo</title>
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
	<h2>ComboBox</h2>
	<p>Click the buttons below to perform actions.</p>
	
	<div style="margin:20px 0;">
		<a href="javascript:void(0)" class="easyui-linkbutton" οnclick="setvalue()">SetValue</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" οnclick="alert($('#state').combobox('getValue'))">GetValue</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" οnclick="$('#state').combobox('disable')">Disable</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" οnclick="$('#state').combobox('enable')">Enable</a>
	</div>
	<script type="text/javascript">
	var i ;
		function setvalue(){
		/*
			$.messager.prompt('SetValue','Please input the value(CO,NV,UT,etc):',function(v){
				if (v){
					 $.messager.show(
					   {
						title: "电脑监测",						
						msg: "CPU温度过高,请浇凉水",
						showType: 'fade',
						timeout: 5000
					  }
					);
				}
			});
			
			$.messager.alert(
			'这是一个警告框','cpu温度过高','warning',function(){
			}
			);
			
			$.messager.confirm("删除确认","确定要删除吗?",function(data){
				i=data;
				alert(i);
			});
			*/
			$.messager.prompt("输入框","请输入一个数字",function(data){
				$.messager.alert("输入提示框","您输入的数字是:"+data,'info');
			});
		}
	</script>
	
</body>
</html>

如果出现乱码,首先查看页面中是否设置了编码,如果页面中设置了编码uft-8,则可以用记事本打开文件,另存为,查看文件的编码是否和页面编码相同,即是否为utf-8,如果不是,则可以选择utf--8进行保存。乱码即可解决,如果还未解决,则可先以utf-8格式建立一个html文件,然后将出现乱码并且页面编码为utf-8的html内容拷贝进来,则乱码可被解决。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值