Вид <отделение> элементы с помощью jQuery

В python символ обратной косой черты используется как escape-символ. Если вы делаете \ n, он переводит строку, \ t делает вкладку. Есть много других вещей, таких как \ "позволяет вам сделать кавычку в строке. Если вы хотите регулярную обратную косую черту, вы должны сделать" \\ "

9
задан Vegard Larsen 16 February 2009 в 11:31
поделиться

1 ответ

Править: Вот некоторый код, который должен сделать то, что Вы после. Здесь select_1, select_2, и т.д. должны быть идентификаторы раскрытия. getDropdown() должна быть функция, которая возвращает выбранное значение данного выпадающего идентификатора с помощью выбора метода (document.getElementById().options.selectedIndex,, jQuery, и т.д.)

<div id="parent">
    <div id="child1">
        ..content
        <select id="select_1">...content</select>
    </div>

    <div id="child2">
        ..content
        <select id="select_2">...content</select>
    </div>

    <div id="child3">
        ..content
        <select id="select_3">...content</select>
    </div>
</div>

 function sortValues()
    {
        /*Save the contents of each div in an array 
          so they can be looped through and 
          re inserted later*/
        var content=[$("#child1").html(),$("#child2").html,$("#child3").html()];

        //Get the value of all dropdowns and sort them
        var sortedArray=[getDropdown("select_3"),getDropdown("select_2"),getDropdown("select_3")];
        var sortedContent=new Array();
        sortedArray.sort();

        /*Loop through all the sorted values, 
         compare the value of each dropdown
         against the sorted value and use that 
         to determine the new arrangement of the divs
         */
        for (x=0; x< sortedArray.length; x++)
        {
            for (y=0; y<=content.length; y++)
            {
                if (getDropdown("dropdown_" + (y+1))==sortedArray[x])
                {
                    sortedContent[x]=content[x];
                               //This will prevent the same div from being assigned again:
                    $("#select_" + (y+1)).remove(); 
                    break;
                }

            }

        }
        /* Empty the parent div so new divs can be inserted.
           You can also do a fadeout/fadeIn of the div here
         */


        $("#parent").empty();       

        for (x=0; x< sortedContent.length; x++)
        {
            $("#parent").append(sortedContent[x]);
        }
    }
4
ответ дан 5 December 2019 в 01:19
поделиться
Другие вопросы по тегам:

Похожие вопросы: