What is the difference between D3 and jQuery?

前端 未结 7 845
挽巷
挽巷 2021-01-29 23:54

Referring to this example:

http://vallandingham.me/stepper_steps.html

it seems that the D3 and jQuery libraries are very similar in the sense that they both do D

7条回答
  •  有刺的猬
    2021-01-30 00:19

    I've been using a little of both lately. Since d3 uses Sizzle's selectors you can pretty much mix up selectors.

    Just keep in mind d3.select('#mydiv') doesn't return quite the same as jQuery('#mydiv'). It's the same DOM element, but it's being instantiated with different constructors. For example, let's say you have the following element:

    And let's grab some common methods:

    > d3.select('#mydiv').attr('rel') ;
     "awesome div"
    
    > jQuery('#mydiv').attr('rel');
     "awesome div"
    

    Seems legit. But if you go a little further:

    > d3.select('#mydiv').data();
     [undefined]
    
    > jQuery('#mydiv').data();
     Object {hash: "654687867asaj"}
    

提交回复
热议问题