append()

html()의 차이점은 


append는 앞에 있는 것들을 살려주고 

html은 앞에 있는것들을 다 지우고 다시 쓰는듯함. 정확한지 모르겠네 여튼 

html쓰면 아래서 안됨. 


var barDiv = $('<div/>');

barDiv.attr('id', 'sidebar').html("<hr> <h2> why not!</h2>");


var btnDiv = $('<div/>');

btnDiv.attr('id', 'btnArea');

            

             $('#dataGridDiv').append(barDiv);

            $('#dataGridDiv').append(btnDiv);

            $('#dataGridDiv').append("<p>All new content. <em>You bet!</em></p>");




var barDiv = $('<div/>');

barDiv.attr('id', 'sidebar').html("<hr> <h2> why not!</h2>");


var btnDiv = $('<div/>');

btnDiv.attr('id', 'btnArea');

            

             $('#dataGridDiv').append(barDiv);

            $('#dataGridDiv').append(btnDiv);

            $('#dataGridDiv').html("<p>All new content. <em>You bet!</em></p>");




은빛늑대
조회 수 : 3350
2008.11.04 (22:36:38)
아래 글자에 각각 마우스 포인터를 올려 보세요.

Auto
Crosshair
Default
Pointer
Move
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
text
wait
help
Hide cursor


Hide cursor를 대강 보시면 아시겠지만 커서를 없앤다는 것은 불가하구요.
투명커서를 넣으면 화면에서는 어짜피 사라지니까 효과가 같겠죠.
커서를 직접 제작하시려면 Microangelo Studio를 사용하셔서
편집하거나 새로 만드시면 됩니다.

------------------HTML소스--------------------------
<span style="cursor:auto">
Auto</span><br>
<span style="cursor:crosshair">
Crosshair</span><br>
<span style="cursor:default">
Default</span><br>
<span style="cursor:pointer">
Pointer</span><br>
<span style="cursor:move">
Move</span><br>
<span style="cursor:e-resize">
e-resize</span><br>
<span style="cursor:ne-resize">
ne-resize</span><br>
<span style="cursor:nw-resize">
nw-resize</span><br>
<span style="cursor:n-resize">
n-resize</span><br>
<span style="cursor:se-resize">
se-resize</span><br>
<span style="cursor:sw-resize">
sw-resize</span><br>
<span style="cursor:s-resize">
s-resize</span><br>
<span style="cursor:w-resize">
w-resize</span><br>
<span style="cursor:text">
text</span><br>
<span style="cursor:wait">
wait</span><br>
<span style="cursor:help">
help</span><br>
<span style="cursor:url(http://myhome.naver.com/apropos/temp/style.cur)">
Hide cursor</span>
<br> 

[출처] 커서 모양 바꾸기|작성자 또식이


JAVA JDK 설치 --> 환경변수 잡기 ( 내컴퓨터 - 고급 -  환경변수 - 추가 - 변경)

이클립스 설치   --> 워크 스페이스 설정( 보통 user/사용자명/ workspace) 이다. 



신입개발자 생존의 기술 지속적 성장을 위한 33가지 실천법 (올해 한 7-8번쯤째 읽은 책.)


올해는 유난히 책을 안?못? 읽고 있다. 뭐 여러가지 상황이 겹처서 그렇다지만 충분히 반성할 부분이다. 


이 책은 사실 올 2월쯤구입해서 읽다가 중간에 그만뒀었다. 개발 경력을 이제 막 시작하는 나에게는 아직도 어렵기만 한 책이었다. 근데 이제 조금 회사의 생리를 알게되니 좀 다가 오기도 한다. 그래서 다시 읽기 시작했다. 

앞부분은 기술적 부분이었다. 코드를 어떻게 짜고, 어떻게 디버깅 해라 뭐 이런것들?? (사실 기억이 나지 않는다. 오래되서 ㅠㅠ)

뒷부분은 인간관계와 회사내에서 각 사람들이 맞은 역할들을 이해할수 있도록, 그리고 내가 그 사람들과 어떻게, 어떤 방식으로 다가가서 관계맺는 것이 좋은지 적어주었다. 

그리고 마지막쯤에는 앞으로 어떤 커리어를 가져갈 것인지 적어주었다. 뭐 사실 아직 와 닿는 것이 거의 없지만, 이런 길이 있겠거니... 싶었다. 

책을 가져다가 다시 살피면저 정리해야 하는데 이건 뭐.... 엉망이네..








원문 출처 : http://stackoverflow.com/questions/9122078/difference-between-onclick-vs-click





Is there any difference between $('#whatever').on('click', function() and $('#whatever').click(function() ?




I think, the difference is in usage patterns. ( 사용패턴이 다름)

I would prefer .on over .click because the former can use less memory and work for dynamically added elements. 

(on을 click 보다 좋아하는 이유는 메모리를 덜먹고 동적으로 생성되는 요소들이 잘 작동하기 때문임)

Consider the following html: (아래 코드좀 살펴보자)

<html>
    <button id="add">Add new</button>
    <div id="container">
        <button class="alert">alert!</button>
    </div>
</html>

where we add new buttons via ( 아래 코드로 새로운 버튼을 만들어 보자)

$("button#add").click(function() {
    var html = "<button class='alert'>Alert!</button>";
    $("button.alert:last").parent().append(html);
});

and want "Alert!" to show an alert. We can use either "click" or "on" for that. ( Alert! 가 뜰것이다. on이나 click이나 다 쓸수 있다.)


클릭을 쓸때 When we use click

$("button.alert").click(function() {
    alert(1);
});

with the above, a separate handler gets created for every single element that matches the selector. That means

  1. many matching elements would create many identical handlers and thus increase memory footprint
  2. dynamically added items won't have the handler - ie, in the above html the newly added "Alert!" buttons won't work unless you rebind the handler.
1. 많은 요소들은 많은 개별 핸들러를 필요로 해서 메모리 사용량이 증가됨.
2. 돌적으로 추가된 요소들은 기존의 핸들러들이 안 먹힘. 예를들어. 위의 html에서 새롭게 추가된 Alert!버튼은 rebind 해주지 않는 이상 동작 안함.

온을 쓸때 When we use .on

$("div#container").on('click', 'button.alert', function() {
    alert(1);
});

with the above, a single handler for all elements that match your selector, including the ones created dynamically.

위 코드를 보면, 하나의 핸들러가 동적으로 새롭게 만들어지는 요소들을 포함해서, 대응되는 모든 요소들을 다루고 있다. 


온을 쓰는 다른 이유들....another reason to use .on

As Adrien commented below, another reason to use .on is namespaced events. (네임스페이스 이벤트 때문임)

If you add a handler with .on("click", handler) you normally remove it with .off("click", handler) which will remove that very handler. Obviously this works only if you have a reference to the function, so what if you don't ? You use namespaces:

만약 .on("click", handler) 로 추가하면 .off("click", handler) 로 보통 없앨수 있다. 참조할 함수가 있다면 확실히 작동한다. 근데 없다면?? 네임스페이스를 써라.     

$("#element").on("click.someNamespace", function() { console.log("anonymous!"); });

with unbinding via ( 아래 코드를 묶음 풀기)

$("#element").off("click.someNamespace");
share|improve this answer


+ Recent posts