Home Web Front-end HTML Tutorial HTML learning summary 10_html/css_WEB-ITnose

HTML learning summary 10_html/css_WEB-ITnose

Jun 24, 2016 am 11:46 AM

1、加入JavaScript和外部内容

  (1)画布介绍

    画布元素是一个自由格式的区域,在这里你可以通过用图像、手工制图、动画和文本来提升网页的用户提样。

    可以用适当的标记符在网页上加上一个画布元素。像其他HTML标记符一样,标记符也有属性,最基本的属性是网页中画布的高和宽。创建一个       200x200画布可以使用以下代码:

    

    标记符什么也没做,他实际上是一个空白区域,我们可以利用现在浏览器能明白的编程语言JavaScript来赋予画布新的生命。

2、JavaScript

  JavaScript不是Java、它基本上和Java编程语言没有什么关系。

  使用程式库或框架技术可以让JavaScript在所有流行的浏览器中以同样的方式工作,其中一种流行的框架技术称为jQuery

3、在网页中加入JavaScript,需要加入<script>标记符。具体来说,开始标记符应该是这样的:</p> <p>  <script type="text/ javascript"></p> <p>  结束标记符应该像下面这样:</script>

  在开始标记符和结束标记符中间正是你要插入JavaScript代码的地方。<script>标记符通常包含src属性,该属性说明,网页插入了外部的JavaScript文件。例如:有一个     JavaScript文件,它的文件名是“myjavascript.js",则应该以这样的的方式加入该文件。</p> <p>  <script type="text/javascript" src="myjavascript.js"></script>

4、用户的浏览器可能禁用JavaScript

  有些用户浏览器禁用JavaScript或者一些用户没有安装最新版本的浏览器Web浏览器,很多原因使用户不愿意启用JavaScript,为了网站在没有JavaScript的情况下依然可以工   作,你要确保JavaScript以适当的方式发出错误信息。

  检验JavaScript是否被启用的方法是使用

5、JavaScript事件和jQuery

  jQuery是一个开源的JavaScript文件,它不仅省略了开发人员索要处理的跨浏览器兼容性的问题,而且简化了JavaScript初学者所所不具备的高级编程技术,jQuery的      JavaScript框架,对于JavaScript事件和所有常见的JavaScript来说,都是非常理想的编程工具。

6、获取jQuery工具

  可以从http://jquery.com下载jQury。jQuery只有一个文件,将它放在网站的文档的根目录处或主文件夹下(或具体环境中放置JavaScript文件的地方)

7、jQuery中有一个函数叫.ready()。它只会在浏览器完全装载网页并且已经为JavaScript准备好了后才会执行。jQuery代码以$符号开头和括号开始。

  例如:

   

     

      

         Document Ready

        

      

      

      

       

      

8、

  (1)用jQuery来选择元素,例如:

等。

  HTML代码带有一个

元素,它的id属性,设置为contentDiv:

  

Your first JavaScript Page.

  如果使用jQuery,以下的语法会使选择元素变得简单:

  

Your first JavaScript page.

 $("#contentDiv")

 You can also use the following syntax to select all

elements:

 $(".classname")

 (2)jQuery also provides several other methods to select elements, including the layering function, through which you can select the sub-elements of an element; or select all other elements except the specified element; or Select an element's parent elements

or use any of the many other selectors.

Please see an additional example;

🎜>   

   iQuery 101

body>

    
Your second Javascript page.

   

    $("#contentDiv").css("backgroundColor","#abacab");

  $("#contentDiv") .click(function(){

    $(this).fadeout(5000);});

  

  

 

 Note that the click function is directly attached to

, where the id variable is equal to contentDiv. Within the .click() function, it calls another function called .fadeOut() (an anonymous function enclosed in curly braces). Note that here, there is a new part, the $(this) tag. The $(this) tag refers to the element that generated the event, so this example specifies the contentDiv element, which can also be written in the following way:

 $("contentDiv").click(function(){ $("contentDiv").fadeout(5000);})

10. Use jQuery and JavaScript to validate the form

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

See all articles