Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5937869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:36:12+00:00 2026-05-22T15:36:12+00:00

I have the following code: var div = $(<div id=’3.5′>AA</div>); div_id_after = Math.floor(parseFloat(div.get(0).id)); $(‘#’+div_id_after).after(div);

  • 0

I have the following code:

var div = $("<div id='3.5'>AA</div>");
div_id_after = Math.floor(parseFloat(div.get(0).id));

$('#'+div_id_after).after(div);


<div id='1'>a</div>
<div id='2'>b</div>
<div id='3'>c</div>
<div id='4'>d</div>
<div id='5'>e</div>

This will produce the divs in this order:

a
b
c
AA
d
e

Clearly, it is not proper to use a number as an ID for IE/netscape compatibility issues, but bear with me.

If you have divs which are created with a custom attribute “order”, where the value of this attribute is a TimeStamp:

<div order='2011-05-13 15:57:09'>a</div>
<div order='2011-05-14 11:23:02'>b</div>
<div order='2011-05-19 10:12:11'>c</div>
<div order='2011-06-10 12:39:37'>d</div>
<div order='2011-06-12 13:47:17'>e</div>

And, as in the code above you have an element:

var div = $("<div object='2011-05-19 17:46:21'>AA</div>");

How would you order these items, like the example above?

  • 1 1 Answer
  • 4 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:36:13+00:00Added an answer on May 22, 2026 at 3:36 pm

    Something like this (assumes that there is a parent div wrapping all of your items, id’d ‘container’).

    $(document).ready(function(){
      $('#sort_me').click(doOrder);
    });
    
    function orderSort(a,b)
    {
       return ($(a).attr('order') > $(b).attr('order')) ? 1 : -1;
    }
    
    function doOrder()
    {
       var orderable = [];
       $('div[order]').each(function(idx,el){
          orderable.push(el);
       });
       orderable.sort(orderSort);
       for (var i=0; i < orderable.length;i++)
       {
            // Somewhat slow way of doing this.  Should be fine until you
            // get above 200 entries or so.  There are other ways which may 
            // be faster, but I thought this was good for explanation.
            $('#container').append(orderable[i]);
       }
    } 
    

    added:
    Forgot to add my fiddle: http://jsfiddle.net/fUC2A/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code var replyName = "1"; var test = "<div id=replyName></div>"
I have two <div> elements, and the following JavaScript code: var myObject = {
I have the following code: var tempIdx = document.getElementById('cityBuild').selectedIndex; var tempBuilding = document.getElementById('cityBuild').options[tempIdx].value; //
How do I access user preferences in Firefox? I have the following code: var
I have the following code in my controller: public ActionResult Details(int id) { var
I have code similar to the following in many places: var dbParams = db.ReadParams(memberID,
I have the following code: var shadow = #FF00FF 0 50px 90px inset; $('#element').find('a.thumbnail').hover(function()
I have the following code - <script type=text/javascript> function test() { var results =
I have the following code: <div id=object-container> <object data=some-file.swf> <param name=src value=some-file.swf /> </object>
I have the following code: <div id=leaving-dialog title=Confirmation Required> <p>You are now leaving the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.