lucheng918的个人博客分享 http://blog.sciencenet.cn/u/lucheng918

博文

javascript小程序(1)

已有 2797 次阅读 2014-5-19 17:33 |个人分类:技术控|系统分类:科研笔记

//实现功能:html页面点击button修改页面内容;判断input输入框中的输入内容是否为数字


<!DOCTYPE html>

<html>

<body>


<h1>这就是爱情~</h1>


<p id="demo">

我的生活,缺你不可

<script>

alert('你来了?');

alert('等你很久了');

document.write("<h1>我想说</h1>");

</script>


<script>

function myfunction(){

x=document.getElementById("demo");  //改变html文本

x.innerHTML="所以,forever";

}

function  isNO(){

var x=document.getElementById("identify").value;

if(x==""||isNaN(x)){   //判断是否是数字

alert("输入数字呀~"+x);

}

}

</script>

<button type="button" onclick="myfunction()">改变</button>

<button type="button" onclick="alert('我爱你')">点击这里</button>

<input id="identify" type="text">

<button type="button" onclick="isNO()">输入一个数字</button>

</body>

</html>




https://wap.sciencenet.cn/blog-780964-795851.html

上一篇:参数——设置sql server2012 决策树算法
下一篇:几个不错的政府网站展现形式
收藏 IP: 202.108.145.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-21 22:01

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部