SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    820
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    don't get this JS/jQ test...

    mayacove.com/dev/js_test.html

    I don't get this test... I don't see an array defined anywhere.... ("defined in the array "product_features"....)

    (also: how do you move elements in jQuery from one element to another? I have done lots of things in jQuery, but never have had to move elements from one container to another...)

    in the end I didn't have to do this test, because they said the position was filled after they had sent me the test, but I still would like to tackle it...

    thank you...

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by maya90 View Post
    mayacove.com/dev/js_test.html

    I don't get this test... I don't see an array defined anywhere.... ("defined in the array "product_features"....)
    You are expected to create the array, and populate it with strings that would be matched against class names.

    Quote Originally Posted by maya90 View Post
    (also: how do you move elements in jQuery from one element to another? I have done lots of things in jQuery, but never have had to move elements from one container to another...)
    That would be with the appendChild method.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    820
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    so it turns out there is an array there, hadn't seen it..

    Code:
    var product_features = ['draggable','trackable','colorable'];
    so I did:

    Code:
            var prod_features = $('.draggable,.trackable,.colorable');
    	$('#output').append(prod_features);
    which did exactly what they wanted... :-) but they probably want me to do it using the array.. how would I do this using the array??

    also, found something very interesting...

    I thought I would have to first remove the elements I need to move to the other div (there is a .remove() method), but it turns out that .append moves them, i.e., it removes elements from where they are, meaning it moves the elements, it doesn't copy them.. that's cool.. (so what if you want to copy them??)

    thank you....

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,839
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by maya90 View Post
    I thought I would have to first remove the elements I need to move to the other div (there is a .remove() method), but it turns out that .append moves them, i.e., it removes elements from where they are, meaning it moves the elements, it doesn't copy them.. that's cool.. (so what if you want to copy them??).
    If you want to copy elements then use cloneNode to create a copy first and then append the copy.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •