w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Wrap child to parent element with child position inherited

Change your script will following script

      $(document).ready(function(){
      //=============================
      // Data Entry
      //=============================
      var countries = [
         { value: 'Andorra', data: 'AD' },
         { value: 'Banana', data: 'BN' },
         { value: 'Cat', data: 'CA' },
         { value: 'Dog', data: 'DO' },
         { value: 'Zimbabwe', data: 'ZZ' }
      ];

      //=============================
      // Select Suggestion Action
      //=============================
      $('#autocomplete').autocomplete({
          lookup: countries,
          onSelect: function (suggestion) {
              alert('You selected: ' + suggestion.value + ', ' +
suggestion.data);
          }
      });

      //===============================
      // Code Tweak
      //===============================
      $('#autocomplete').keyup(function(){
        var suggestions_visible =
$('.autocomplete-suggestions').is(":visible");
        var suggestions_childLength =
$('.autocomplete-suggestions').children().length;

        if (suggestions_visible && suggestions_childLength > 0){
          //=================================
          // Wrap text-suggestion and picture-box

          // *****************************************************
          // *                autocomplete-wrapper               *
          // *  *********************** ************************ *
          // *  *   text-suggestion   * *     picture-box      * *
          // *  *                     * *                      * *
          // *  *********************** * ********************** *
          // *****************************************************

          var text_suggestion =
$('.autocomplete-suggestions').addClass('col-lg-4 col-md-4');
           $( '.autocomplete-suggestions' ).wrap( "<div
class='new'></div>" );
              picture_box = '<div class="col-lg-8
col-md-8"></div>';
           $('.autocomplete-suggestions').append(picture_box);
              //wrapper =
$('#autocomplete-wrapper').append(text_suggestion).append(picture_box);

        }
      });



    });

The above script will wrap the autocomplete-suggestions div into div with class new

and append new div into autocomplete-suggestions

Do ask for help





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.