js获取和设置属性

function square(num){
    var total = num*num;//局部变量
    return total;
}
var total = 50;//全局变量
var number = square(20);
alert(total);//结果为50

function square(num){
    total = num*num;//全局变量
    return total;
}
var total = 50;//全局变量
var number = square(20);
alert(total);//结果为400
这细微的差别就会影响到程序的结果

body{
    color:white;
    background-color:black;
}
这些颜色不仅作用于那些直接包含在<body>标签里的内容,还将作用于嵌套在body元素内的所有元素

id属性就像一个挂钩,它一头连着文档里的某个元素,另一头连着CSS样式表里的某个样式

document.getElementById("purchases")这个调用将返回一个对象,这个对象对应着document对象里的一个独一无二的元素,那个元素
的的id属性值为purchases

其实,文档中的每个元素都是一个对象。利用DOM提供的方法能够得到任何一个对象。

getElementsByTagName返回一个数组,即使整个文档里只有一个元素,也返回一个数组。
示例:
var items = document.getElementsByTagName("li");
for(var i = 0;i<items.length;i++){
    alert(typeof items[i]);
}
显示信息都是object

☞getElementByClassName
也返回一个具有相同类名的元素数组

☞获取和设置属性
❤getAttribute
object.getAttribute(attribute)
注:getAttribute方法不属于document对象,它只能通过元素节点对象调用。
❤setAttribute
object.setAttribute(attribute,value)
例子:
var shopping = document.getElementById("purchases");
shopping.setAttribute("title","a list of goods");

转载于:https://www.cnblogs.com/jiqing9006/archive/2013/03/01/2938394.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/274344.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

hp-ux锁定用户密码_我们如何简化925移动应用程序的用户入门— UX案例研究

hp-ux锁定用户密码Prologue: While this is fundamentally a showcase of our process in the hopes of helping others, it’s also a story about the realism of limitations when working with clients and how we ultimately were able to deliver a product the client w…

微信公众号无需二次登录_您无需两次解决问题-您需要一个设计系统

微信公众号无需二次登录重点 (Top highlight)The design system concept can be differently defined according to each person’s background. Designers may say that a design system is a style guide while developers may say it is UI standards, or specs, or even as…

android中AsyncTask和Handler对比

1 &#xff09; AsyncTask实现的原理,和适用的优缺点 AsyncTask,是android提供的轻量级的异步类,可以直接继承AsyncTask,在类中实现异步操作,并提供接口反馈当前异步执行的程度(可以通过接口实现UI进度更新),最后反馈执行的结果给UI主线程. 使用的优点: l 简单,快捷 l 过程可…

视觉工程师面试指南_选择正确视觉效果的终极指南

视觉工程师面试指南When it comes to effective data visualization, the very first and also the most critical step is to select the right graph/visual for the data that you want to present. With a wide range of visualization software that is available offerin…

在 Linux 下使用 水星MW150cus (RTL8188CUS芯片)无线网卡

Fedora &#xff08;如果你不使用 PAE 内核&#xff0c;请去掉 PAE 字样&#xff09;:yum install gcc kernel-PAE kernel-PAE-devel kernel-headers dkms Ubuntu: apt-get install make gcc linux-kernel-devel linux-headers-uname -r安装原生驱动 注意&#xff1a;由于在 Li…

问题反馈模板_使用此模板可获得更好,更有价值的UX反馈

问题反馈模板Feedback is an important part of UX design. To improve the work you do you need to be able to give and receive feedback. Receiving valuable feedback is for a very large part up to you.反馈是UX设计的重要组成部分。 为了改进您的工作&#xff0c;您需…

【转载】Android Animation 简介(官方文档翻译) ---- 翻译的很好!

http://vaero.blog.51cto.com/4350852/849783转载于:https://www.cnblogs.com/DonkeyTomy/articles/2945687.html

ubuntu 如何转换 ppk ,连接 amazon ec2

转 自 &#xff1a;http://www.ehow.com/how_8658327_convert-ppk-ssh-ubuntu.html1 Open a terminal window in Ubuntu, or log in if you are converting the keys on a remote Ubuntu server. 2 Type "sudo apt-get install putty-tools" at the terminal prompt …

iofd:文件描述符_文字很重要:谈论设计时18个有意义的描述符

iofd:文件描述符As designers, many of us think we’re just visual creatures. But creating visuals is only half of the job. The other half is verbal communication — actually talking about design. Whether we’re showcasing our own work, giving or receiving c…

保护程序猿滴眼睛-----修改VS 2008 编辑器颜色 (修改 chrome浏览器的背景色)

前几天更改了 chrome 的背景色后&#xff0c;虽然有些地方看起来不和谐&#xff0c;想百度的首页&#xff0c;显示出了大快的图片区域&#xff0c;但是&#xff0c;整体感觉这个颜色设置真的对眼睛有一定保护作用。。。 所以&#xff0c;再顺便修改一下 经常用的 vs2008 编辑器…

数据可视化 信息可视化_可视化哲学的黎明

数据可视化 信息可视化Note: this is the foreword of the book Data Visualization in Society (Amsterdam University Press, 2020)注意&#xff1a;这是《 社会中的数据可视化 》一书的前言 (阿姆斯特丹大学出版社&#xff0c;2020年) Geographer John Pickles once wrote …

HTTP 错误 404.2 - Not Found 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面...

详细错误&#xff1a;HTTP 错误 404.2 - Not Found. 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置&#xff0c;无法提供您请求的页面. 出现环境&#xff1a;win7 IIS7.0 解决办法&#xff1a;IIS的根节点->右侧“ISAPI和CGI限制”->把禁止的DotNet版本项设置为允许…

重口味动漫_每种口味的图标样式

重口味动漫The icons are, without a doubt, one of the most used graphic elements today in the interface design of digital products. And to make this statement with some degree of certainty, we do not even need a very robust statistical analysis. Just rememb…

JSP入门

一、什么是JSP&#xff1f; JSP&#xff08;Java Server Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术&#xff0c;它是在传统的网页HTML文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag)&#xff0…

初学c++

看了两章不到。。随意记录下。 #include<iostream> #include<string> using std::cout; using std::endl; double calculation(double a,double b,char op) {switch(op){case : return ab;case -:return a-b;case *:return a*b;case /:return a/b;}}double num0;do…

从头开始vue创建项目_我正在以设计师的身份开始一个被动的收入项目。 从头开始。...

从头开始vue创建项目Do you ever read an article on Medium (or elsewhere) about passive income, side projects and big money making blogs? When I read such an article it looks like it is easy to do yourself if you just put in the work. To see if that is the …

Exaple2_1(显示转换)

public class Example2_1{ public static void main(String arg[]){ char ca; System.out.println(""c"unicode:"(int)c); System.out.println(":"); for(int i(int)c;i<c25;i){ System.out.println(""(char)i); } }}转载于…

英国文化影响管理风格_文化如何影响用户体验

英国文化影响管理风格重点 (Top highlight)The Internet makes the world a smaller place. You can make money or gain users outside of your demographic with a digital product or service easier than a physical business. But, is selling the exact same design of t…

ubuntu12.04安装教程

第一部分&#xff1a;准备Ubuntu12.04的启动盘 Ubuntu支持可移动盘和CDROM安装&#xff0c;笔者选择后者。在Ubuntu官网http://www.ubuntu.org.cn/download/desktop下载Ubuntu镜像文件(.iso)&#xff0c;通过光盘刻录机将该镜像文件刻录到一张空白CD/DVD上。 第二部分&#xff…

element ui 空格_空格是您的UI朋友。 大量使用它。

element ui 空格Originally published at marcandrew.me on July 30th, 2020.最初于 2020 年7月30日 在 marcandrew.me 上 发布 。 Ah good old White Space. One of the simplest things to add to your designs to improve both your UIs, and user experience. Let me shar…