How to move a div inside another using function() [on hold]

218
December 26, 2017, at 03:56 AM

I want to move the position of a div from where it is created in my php document and move it to another location in the file.

I want to create a div around line 11, and then use the variables created in each row and then move the newly created div inside: div class="selector">

This is what my script looks like currently:

 <div class="selector" onclick="showChannels()";><div id="channel">hi</div></div> 
        <div id="cCwrapper"> 
        <?php include 'clientConnections.php';?> 
         <?php 
            $sql = "SELECT icon, pageName, Channel FROM clientconnections"; 
            $result = $conn->query($sql); 
 
            if ($result->num_rows > 0) { 
            // output data of each row 
            while($row = $result->fetch_assoc()) { 
            echo  
            '<div class="itemWrapper" onclick="selectChannels()"> 
            <div class="iconWrapper"> 
            <img src="'. 
            $row["icon"]. 
            '" style="height: 16px; height: 16px;> 
            </div> <!--closes icon wrapper--> 
            <div class="channelWrapper">'. 
            $row["pageName"].  
            '</div> <!-- closes channel wrapper--> 
            </div> <!--closes item wrapper--> 
            '; 
        } 
            } else { 
            echo "Oops! We can't find your connected accounts!"; 
        } 
        ?>

Answer 1
function showChannels(){
  $("#selected_new_element").html($(this)[0].outerHTML); // moving div.selector element inside #selected_new_element (replace html value with this one)
  $("#selected_new_element").append($(this)[0].outerHTML); // appending div.selector element inside #selected_new_element
  $(this).remove(); // remove current element, for "moving" element
}

Some good reference :

  1. http://api.jquery.com/html/
  2. http://api.jquery.com/append/
  3. https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML
  4. https://api.jquery.com/remove/
READ ALSO
jquery-editable-select issue with IE

jquery-editable-select issue with IE

I'm using the plugin jquery editable select to display an editable select

166
how show not all markers on google maps ?

how show not all markers on google maps ?

for me is too difficult show NOT ALL markers on google mapsI have many markers and each has a zIndex

213