program tip

새 버전의 jQuery에서 가장 기대하는 것은 무엇입니까?

radiobox 2021. 1. 9. 09:40
반응형

새 버전의 jQuery에서 가장 기대하는 것은 무엇입니까?


최근 새로운 jQuery 버전 인 jQuery v1.4가 출시되었습니다. 여기에서 모든 내용을 읽을 수 있습니다 . 다음과 같은 매우 깔끔한 작업을 수행 할 수 있습니다.

$("div.test").bind({
  click: function(){
    $(this).addClass("active");
  },
  mouseenter: function(){
    $(this).addClass("inside");
  },
  mouseleave: function(){
    $(this).removeClass("inside");
  }
});

이 새 버전에서 가장 마음에 드는 점은 무엇입니까? 당신을 "최종!"으로 만든 것은 무엇입니까?


더 많은 피드백을 받고 답변을 수락 할 수있는 현상금을 추가했습니다.


내 생각에 가장 좋은 기능은 setter에서 기능을 허용하는 것입니다.

jQuery('li.selected').html(function(i, li) {
   return "<strong>" + li + "</strong>";
});

$ .each가 필요한 많은 코드를 지금 제거 할 수 있습니다.


믿거 나 말거나 저에게 "마지막"순간은 다음과 같은 추가였습니다 delay().

$("#notice").slideDown('500').delay(4000).slideUp('500'); // = Pure awesome :)

모든 속성을 두 번째 인수로 전달하여보다 간결한 방식으로 즉석에서 요소를 생성하는 기능 jQuery():

jQuery('<div/>', {
    id: 'foo',
    mouseenter: function() {
        // do stuff
    },
    html: jQuery('<a/>', {
        href: 'http://google.com',
        click: function() {
            // do stuff
        }
    })
});

모든 비 속성 속성은 해당 jQuery 메서드에 매핑됩니다. 따라서 html호출 .html()하고 갖는 click것은 다음을 click통해 이벤트를 바인딩합니다 .click()...


나는 정말로 좋아하는 것이 없습니다. 여기에 이것이 무엇인지 모르는 사람들을위한 15 개의 새로운 기능에 대한 개요가 있습니다.

http://net.tutsplus.com/tutorials/javascript-ajax/jquery-1-4-released-the-15-new-features-you-must-know/


나는 속도 광이기 때문에 속도 향상은 항상 환영합니다.


나를 위해 그것은 다음과 같습니다.

"모든 이벤트는 라이브 이벤트가 될 수 있습니다."

"live ()에서 지원하는 이벤트 중 일부 추가 이벤트를 계산하게되어 매우 자랑 스럽습니다. 1.4에서는 .live ()의 이벤트 위임을 통해 변경, 제출, focusin, focusout, mouseenter 및 mouseleave에 대한 브라우저 간 지원을 도입했습니다."

I've been waiting for this on the change event for ages!


Well the performance improvements are of course something I appreciate, but I guess I can't say it's a "finally" since it's something that's subject to constant improvement :) The DOM-building (Quick Element Construction) syntax looks really convenient, and the detach method also looks quite usable: it allows you to temporarily remove an object from the DOM, but keeps all the handlers assigned to it, so that it'll work just the same way, when reinserted.

I guess there's not so much a lot of things that I've been missing, but now that these new features are out there, there's a bunch that I'm anxious to start using :)


Event delegation for focus and bubble events:


I really like delay() and detach() the most, to be honest. The performance improvements are a huge plus as well but delay() is probably the single most amazing part of it. Simple but ultra useful. No more setTimeouts().


It has been very modular since 1.3+. For example, when you don't need the ajax library, it is nice to build without it. Keep file sizes down.


Call me crazy, but just the added number of tests gives me a warm fuzzy feeling. I almost want to upvote every answer :)_


I think unwrap() is simple, elegant, and you get an innerHTML present at the end!

The new unwrap method will take the children of a given parent and replace said parent with them. Like so:

<body>
    <div>
        <p>this</p> <p>is</p> <p>fun</p>
    </div>
</body>

$('div').unwrap();

<body>
   <p>this</p> <p>is</p> <p>fun</p>
</body>

$.proxy()

To make sure that this always means this rather than that...

Example from here

MyModule = function() {
  this.$div = $('#testdiv');
  this.myString = "Hi! I'm an object property!";

  this.$div.click($.proxy(this.handleClick, this));
};

MyModule.prototype.handleClick = function() {
  console.log(this.myString); // Hi! I'm an object property!
};

var m = new MyModule();

For me, it's the ability to now write event handlers with the live() handler. I know that live was present in the last version (1.3.2) also, but it wasn't fully supported.

This makes the code infinitely simpler especially if you have most of the DOM being created on the fly or via Ajax requests.

More about live here: http://api.jquery.com/live/


live() calls with events such as change is a big one for me. I have been wanting this for sometime now.

ReferenceURL : https://stackoverflow.com/questions/2070375/what-are-you-the-most-excited-about-in-the-new-versions-of-jquery

반응형