0

I have an input field like below :

<div class="login-form col-sm-12">
  <div class="input-div"><input type="text" placeholder="DOB"><img src="http://i.imgur.com/Hu83Y0v.png" 
alt="" class="info">
  </div>
</div>

On that icon click, I want a hover message, for example "Input your age here" which completely hovers the input field.

how can I do it?

Here's the fiddle for the same.

Suraj
  • 2,423
  • 12
  • 39
  • 75

4 Answers4

0

May be something like this

<div id="wrapper">
    <div class="input-div">
      <input type="text" placeholder="DOB" />
      <img src="http://i.imgur.com/Hu83Y0v.png" alt="" class="hover">
      <p class="text">please enter your DOB</p>
    </div>
</div>

#wrapper .text {
position:relative;
bottom:30px;
left:0px;
visibility:hidden;
}

#wrapper:hover .text {
visibility:visible;
}
MGA
  • 511
  • 2
  • 11
0

Try this

$( ".info" )
      .mouseenter(function() {
     var position = $(this).position();
       $(this).after(' <div class="msgShow">Test</div>');
       $('.msgShow').css("left",position.left-100);
       $('.msgShow').css("top",position.top+10);
        $('.msgShow').css('position','absolute');
        $('.msgShow').css('z-index','1000');
      })
      .mouseleave(function() {
         $(this).parent().children(".msgShow").remove();
      });
  • My trouble is not this, I am able to have it, I want the TEST to come over the text field... – Suraj Jan 12 '17 at 07:38
0

I think this is what you need.

$(".info").on("click", function() {

  var message = ($(this).prev("input").attr("message"));
  var input = $(this).prev("input").offset();
  $(this).parent().find(".popup").remove();
  $(this).prev("input").css({"opacity":0});
  $(this).parent().append("<div class='popup'> " + message + "</div>");
  $('.popup').css({
    "position": "absolute",
    "left": $(this).prev("input").position().left,
    "top": $(this).prev("input").position().top,
    "background-color": "#fff",

  })

  var that = $(this);
  setTimeout(function() {
    that.parent().find(".popup").remove();
    that.prev("input").css({"opacity":1});
  }, 3000)

});
.login-form form .input-div {
  position: relative;
  width: 100%;
  float: left;
}
.login-form form input {
  background-color: #ebf7fa;
  border: 0px;
  font-size: 14px;
  color: #000;
  outline: none;
  border-rad ius: 5px;
  height: 40px;
  line-height: 15px;
  margin-bottom: 10px;
  padding: 0 5px 0 45px;
  width: 100%;
  display: block;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="login-form col-sm-12">
  <div class="input-div">
    <input type="text" placeholder="DOB" message="Input your age here">
    <img src="http://i.imgur.com/Hu83Y0v.png" alt="" class="info">
  </div>
</div>
Deep
  • 9,594
  • 2
  • 21
  • 33
  • @Suraj : put where ? , the solution snippet is as per the requirement correct? I have tried to make solution generic so do add the message attribute in your input – Deep Jan 12 '17 at 08:21
  • @Suraj did this help – Deep Jan 12 '17 at 08:32
0

try this span appears over textbox text..

$(document).ready(function() { 



$(".info").next().slideToggle();






mouseenter: function() {
   $(this).next().slideToggle();
},
mouseleave: function() {
   $(this).next().slideToggle();
},
click: function() {
    // Handle click...
}

});});

<div class="input-div"><input type="text" placeholder="DOB"><img src="" Alt="" class="info"/> <span class="span">Enter DOB here</span></div>

  .span{
  position: absolute;
top: 17px;
left: 11px;
transition: right 0.2s;

}
sri_rcnu
  • 101
  • 6