반응형

$(document).ready(function()){});  = $(function(){});




selector의 기본 개념

SyntaxDescription
$("*")Selects all elements
$(this)Selects the current HTML element
$("p.intro")Selects all <p> elements with class="intro"
$("p:first")Selects the first <p> element
$("ul li:first")Selects the first <li> element of the first <ul>
$("ul li:first-child")Selects the first <li> element of every <ul>
$("[href]")Selects all elements with an href attribute
$("a[target='_blank']")Selects all <a> elements with a target attribute value equal to "_blank"
$("a[target!='_blank']")Selects all <a> elements with a target attribute value NOT equal to "_blank"
$(":button")Selects all <button> elements and <input> elements of type="button"
$("tr:even")Selects all even <tr> elements
$("tr:odd")Selects all odd <tr> elements

딱 보고 다알아야지  - 



마우스 이벤트에 관한 것들.

Mouse EventsKeyboard EventsForm EventsDocument/Window Events
clickkeypresssubmitload
dblclickkeydownchangeresize
mouseenterkeyupfocusscroll

mouseleave

 

blur

unload

mousedown()

The function is executed, when the left, middle or right mouse button is pressed down, while the mouse is over the HTML element:


mouseup()

The function is executed, when the left, middle or right mouse button is released, while the mouse is over the HTML element:


hover()

The first function is executed when the mouse enters the HTML element, and the second function is executed when the mouse leaves the HTML element:


$("#p1").hover(function(){
    alert("You entered p1!");
},
function(){
    alert("Bye! You now leave p1!");
});


focus()

The function is executed when the form field gets focus:


blur()

The function is executed when the form field loses focus:


on() Example

$("p").on("click"function(){
    $(this).hide();
});

$("p").on({
    mouseenter: function(){
        $(this).css("background-color""lightgray");
    }, 
    mouseleave: function(){
        $(this).css("background-color""lightblue");
    }, 
    click: function(){
        $(this).css("background-color""yellow");
    } 
});

보고 딱 느끼면 좋다.


form의 change, focus, blur는 좀 알아봐야겠곤..

document/window도 알아봐야겠다.



'프론트엔드 > Javascript' 카테고리의 다른 글

jquery 정리 - effect(w3school)  (0) 2017.03.15
ajax-ie9  (0) 2016.11.29

+ Recent posts