js基础
来源:互联网 发布:数控编程方法 编辑:程序博客网 时间:2024/06/07 05:52
前端js看着总是那么简单,自己写起来确实那么的难,这里主要是给自己做些记录
使用该标签可以直接在html页面输出文字
<script>document.write("<h1>洪建雄</h1>");document.write("<p>这是一个段落。</p>");document.write("<h1>测试文件</h1>")</script>
点击触发函数
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>基础练习</title> </head><body><p>JavaScript 能够对事件作出反应。比如对按钮的点击:</p><button type="button" onclick="alert('欢迎!')">点我!</button></body></html>
通过javascript改变HTML里面的内容,代码如下:
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head><body><h1>点击触发函数</h1><p id="demo"> 通过js改变内容</p><script>function myFunction(){x=document.getElementById("demo"); // 找到元素x.innerHTML="擦鸟飞翔天!"; // 改变内容}</script><button type="button" onclick="myFunction()">点击</button></body></html>
通过javascript改变HTML里面的内容样式,代码如下:
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>改变内容样式</title> </head><body><h1>JavaScript</h1><script>function myFunction(){doc=document.getElementById("demo") // 找到元素doc.style.color="#ff0000"; // 改变样式}</script><button type="button" onclick="myFunction()">点击这里</button></body></html>
阅读全文
1 0
- js基础
- js基础
- js基础
- js基础
- JS基础
- js基础
- js基础
- JS基础
- js基础
- js基础
- js基础
- js基础
- JS基础
- js 基础
- js-基础
- js基础
- js基础
- js基础
- linux学习网址
- 端口
- Good url for my CV
- Leetcode:714. Best Time to Buy and Sell Stock with Transaction Fee
- [BZOJ1559]-[JSOI2009]密码-补全AC自动机+状压dp
- js基础
- IO流(9)--字符流的三种拷贝
- 再谈Linux内核中的RCU机制
- Java Web 知识总结
- [LeetCode] 154. Find Minimum in Rotated Sorted Array II
- Keras with R (MLP)
- ###Springmvc封装复杂表单数据:表单提交多个实体类的参数【对象类型参数,自动封装】name属性值不能重复。和实体类属性名一致
- 个人学习笔记02-DoTween插件简单运用
- Android项目中加入弹幕功能