单击在输入字段中单击弹出

时间:2015-09-23 12:14:50

标签: javascript jquery html twitter-bootstrap

每个人我对javascript都很陌生我尝试了很多东西来完成这项任务,但我无法做到这一点。 我的Html代码是:

<div class="row  lcf-form">
   <div class="col-xs-4">
      <input type="text" class="form-control" placeholder="All India">
    </div>
   <div class="col-xs-6">
      <input type="text" class="form-control" placeholder="Adds Near You">
    </div>
    <button type="button" class="btn btn-primary">Search</button>
 </div>

我的Js代码:

<script type="text/javascript">
 var started;
  function showLightBox()
   { 
    if (started) return;
    started = setTimeout(function(){
    Lightbox.start(document.getElementById('firstImage'));
    started;
     },500);
   }
   function stopShowLightBox(){
   if (started) {
    clearTimeout(started)
    started = 0;
   }
  }
</script>

我关注此链接popup,但它不适合我。

我希望当我输入光标时,只需打开输入文本的弹出式div。

2 个答案:

答案 0 :(得分:0)

您只需添加要调用函数的onclick事件

试试这个

<div class="col-xs-4">
  <input type="text" class="form-control" placeholder="All India" onClick="showLightBox()">
</div>

答案 1 :(得分:0)

你没有调用 onClick 事件,只需简单地调用ShowLightBox()函数。

<div class="col-xs-4">
  <input type="text" class="form-control" placeholder="All India">
</div>

而不是这个你用这个:

<div class="col-xs-4">
  <input type="text" class="form-control" placeholder="All India" onClick="showLightBox()">
</div>