Solution 1 :

Set z-index: 1 to fetchlist div.

<div id="fetchlist" style="background-color: red;position:absolute; z-index: 1;">

Problem :

I am having problem selecting 3rd item in my list “Puma”.
The problem is when I try to select the item “My Account” come from behind.

I want “My Account” tab remains behind when I select “Nike”, “Reebok”, “Puma”, “Fila”, “Sneaker”

I tried something position abosolute/relative but it did not work for me.

Here is the code: https://jsfiddle.net/fh9cgn15/2/

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>


<style>
  li.myClassT {
    cursor: pointer;
 }
   li:hover {
    background-color: #ccc;
 }
</style>


<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 0.15rem">

  <a class="navbar-brand" href="#" id="newStoreName">Chaos Fast Food</a>
   <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
    <span class="navbar-toggler-icon"></span>
    </button>
  <div id="navb" class="navbar-collapse collapse hide">

  <ul class="navbar-nav">

  <div class="container-fluid">

    <form action="detail.php" method="post">
      <div class="row">
        <div class="input-group">
          <!-- type = "search" -->
          <input class="form-control border-secondary py-2 input-lg" type="text" name="search" id="vsearch" value="" placeholder="search for products" autocomplete="off">
          <div class="input-group-append">
            <button class="btn btn-outline-secondary" type="button">
              <i class="fa fa-search"></i>
            </button>

          </div>

        </div>

      </div>

     <!--  Here is the problem selecting "Puma" the "My Account" comes from behind and "My account" got selected, what I don't want. -->


      <div id="fetchlist" style="background-color: red;position:absolute">
        <ul class="list-unstyled" style="background-color:#eee;cursor:pointer" >
          <li>Nike</li>
          <li>Reebok</li>
          <li>Puma</li>
          <li>Fila</li>
          <li>Sneaker</li>
        </ul>
      </div>

    </form>

  </div>
</ul>

<ul class="nav navbar-nav ml-auto">
  <li class="nav-item">
    <a class="nav-link" href="cart.php"><span class="fa fa-shopping-cart" aria-hidden="true"></span>Cart</a>
  </li>




    <!-- Dropdown -->

           <!--  Here is the problem selecting "Puma" the "My Account" comes from behind and "My account" got selected, what I don't want. -->

  <li class="nav-item dropdown">
   <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">My Account</a>
    <div class="dropdown-menu dropdown-menu-right">
      <a class="dropdown-item" href="#">Profile</a>
      <a class="dropdown-item" href="#">Orders</a>
      <a class="dropdown-item" href="#">Setting</a>

   </div>
  </li>


  </ul>
  </div>
 </nav>



<!-- fetchlist -->
<script>
 $("#fetchlist").on('click','li',function() {
        //alert($(this).text());
        $('#vsearch').val($(this).text());
        $('#fetchlist').fadeOut();
    });

 </script>

By

Leave a Reply

Your email address will not be published. Required fields are marked *