Next, we’ll need to start up our jQuery magic using the $(document).ready(); syntax you’ve seen. It works like this:
$() says, "hey, jQuery things are about to happen!"是把()内的东东转化成jQuery的object,从而有后面的.ready这个method
Putting document between the parentheses tells us that we're about to work our magic on the HTML document itself.
.ready(); is a function, or basic action, in jQuery. It says "hey, I'm going to do stuff as soon as the HTML document is ready!"
Whatever goes in .ready()'s parentheses is the jQuery event that occurs as soon as the HTML document is ready.
<ol><li>Start with the function keywordli><li>Inputs go between ()li><li>Actions go between {}li><liid="no4"class="hide">jQuery is for chumps!li>ol>
这个html列表,我们jQuery可以用CSS的这4种方法来指明:
id
class
nth-child(n)
last-child
// Write your jQuery code on line 3!
$(document).ready(function() {
var $target = $('li#no4') //use an id or class
//var $target = $('li.hide') //use a class
//var $target = $('li:nth-child(4)') //use "nth-child(n)"
//var $target = $('li:last-child') //use "last-child"
$target.fadeOut('fast');
});
this 这个key word在jQuery中可以理解为:当你涉及到诸如mouseenter, click这样的事件类function时,使用this可以在你后续处理动作时指定就是你上次事件指向的那个object,比如有多个div,当你点击了第一个div时,你要让它消失,就在click后用this来让它消失:
到这里就掌握了基本的jQuery用法,完成了对于jQuery函数和selector的学习,接下来要学习jQuery的“modify HTMLElements”
Any time you have questions about what jQuery can do or how it works, you can always check out the jQuery documentation, which covers every aspect of the library. 所以:http://docs.jquery.com/ 是jQuery文档的网站。
7.开始修改HTML中的元素
Dynamically adding elements to our HTML page is a powerful tool—it lets us modify not only the formatting, but the actualstructure of our websites in response to a user's actions. 不仅可以改格式,还可以改页面结构。 不单是这样:
$p = $('p');
还可以是这样:
$p = $("
I'm a new paragraph!
");//把一个String放到$p变量里去
7.1 -Inserting Elements
We can insert our newly created elements using a few jQuery actions.
.append() inserts the specified element as the last child of the target element. .prepend() inserts the specified element as the first child of the target element. If we have a div of class .info,:
$(".info").append("
Stuff!
");//inserts element as the last child of the target
$(".info").prepend("
we have two jQuery functions, .empty() and .remove(), that help us delete content from our pages.
.empty() deletes an element's content and all its descendants(子节点). For instance, if you .empty() an 'ol', you'll also remove all its 'li's and their text.
.remove(), not only deletes an element's content, but deletes the element itself.
Great work! You now know how to dynamically update the content of your HTML page, including adding and removing elements.
Now that you can handle manipulating the DOM on the fly, the hard part is over. In the next two lessons, we'll cover a wider range of jQuery event handlers and effects, which will allow you to apply your core programming skills to a variety of challenges.
"thing to touch" is the HTML element you'll
click on, hover over, or otherwise interact with,
and "thing to affect" is the HTML element that:
fades away, changes size,
or undergoes some other transformation.
我们已经学了很多关于jQuery events,来复习一下基础的东西。
一般是以下的套路:
有时候这些元素是一个或者同样的,你要hover over a
来改变它的不透明度opacity。
有时你要和不同的元素互动,例如你要点击一个button来resize it.
有时候如果你想要一个效果,不要.click 或.hover这样的事件来触发,你可以跳过上面的第二行。
10.总结一下events & actions
10.1 Events:
.click
.hover
.dblclick //double click
.mouseenter
.mouseleave
10.2 Actions:
.fadeOut('fast') //fast, slow, ...
.hide(); //hide
.slideToggle('slow');
...
...
.....Change styles......
.addClass()
.removeClass
下面这个例子是我们常用的鼠标移上来应用一个class,然后移除时候remove that class.
$(document).ready(function(){
$('div' ).hover(
function(){
$(this).addClass('active');
}, //separated by a comma. The comma is very important!
function(){
$(this).removeClass('active');
}
);
});
当你按下键盘时,移动一个屏幕上的物体。用到.keydown()事件和.animate()效果。 .animate()效果有两个输入:动画和执行时间。比如: $('div').animate({left:'+=10px'},500); //.animate({ },100); This will take the first div it finds and move it ten pixels to the right.
$(document).ready(function() {
$(document).keydown(function(key) {
switch(parseInt(key.which,10)) {
// Left arrow key pressed
case 37:
$('img').animate({left: "-=10px"}, 'fast');
break;
// Up Arrow Pressed
case 38:
// Put our code here
$('img').animate({top: "-=10px" }, 'fast');
break;
// Right Arrow Pressed
case 39:
// Put our code here
$('img').animate({left: "+=10px"}, 'fast');
break;
// Down Arrow Pressed
case 40:
// Put our code here
$('img').animate({top: "+=10px"}, 'fast');
break;
}
});
});
13. jQuery UI
jQuery UI 是个神马东东? jQuery UI是个new jQuery Library. jQuery UI includes a number of ultra-fancy animations you can use to make your websites do incredible things. For instance, remember when we lamented that jQuery didn't include a .blowUp() effect for our planet Krypton? Well, that's still true. But jQuery UI has an.effect() effect, and we are totally going to give it the input'explode'. 注意我们include了一个新的script标签,html代码如下:
The .effect() effect has all kinds of magical goodness in it, but it's not the most amazing thing jQuery UI can do. The library has a number of built-in effects that can make your website look sleek and professional with surprisingly little code. jQuery除了.effect()还有很多更专业的效果且占用很少代码,你可以看下面的documentation了解更多: You can learn more in the jQuery UI documentation!
14.一个使用jQuery UI做成的下拉菜单效果
Html:
Behold!
jQuery
jQuery is a JavaScript library that makes your websites look absolutely stunning.
jQuery UI
jQuery UI includes even more jQuery goodness!
JavaScript
JavaScript is a programming language used in web browsers, and it's what powers jQuery and jQuery UI. You can learn about JavaScript in the JavaScript track here on Codecademy.
$(document).ready(function(){
$('ol').selectable(); //enable the css effect ".ui-selected"
//$('ol').sortable();//click and rearrange your list items as you like!
});
这里引入了2个对操作的methods: .selectable() & .sortable()
17. jQuery 里 .accordion() 方法,注意不是according
我们要实现accordion-style dropdown menu了,用.accordion()函数。First, however, we'll need some additional HTML elements.
继承 extends 多态
继承是面向对象最经常使用的特征之一:继承语法是通过继承发、基类的域和方法 //继承就是从现有的类中生成一个新的类,这个新类拥有现有类的所有extends是使用继承的关键字:
在A类中定义属性和方法;
class A{
//定义属性
int age;
//定义方法
public void go
hive DDL语法汇总
1、对表重命名
hive> ALTER TABLE table_name RENAME TO new_table_name;
2、修改表备注
hive> ALTER TABLE table_name SET TBLPROPERTIES ('comment' = new_comm