du5407 2016-04-05 13:07
浏览 145

如何隐藏div onclick并使用jquery显示onclick

i'm integrating a search suggest function in a oscommerce script, the function is working properly but i need to create a div hide onclick and shown on input click using jquery (with animation speed) since when i start typing the div appears but cannot be hidden (i've to refresh the webpage to remove that search suggest div)

The events will be created under this div:

Here i attach the code:

$data = '<div class="search">' . "
" .
        tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'id="frmSearch"') . "
" . //     '     <label class="fl_left">'.MODULE_BOXES_SEARCH_HEADER_BOX_TITLE.': </label>' ."
".
        '       ' . tep_draw_button_search_top() . tep_draw_button(MODULE_BOXES_SEARCH_HEADER_BOX_TITLE) . tep_draw_button_search_bottom() . "
" .
        '       <div class="input-width">' . "
" .
        '       <div class="width-setter">' . "
" .
        tep_draw_input_field('keywords', MODULE_BOXES_SEARCH_HEADER_BOX_INPUT, 'id="txtSearch" onkeyup="searchSuggest(event);" autocomplete="off" size="10" maxlength="300" class="go fl_left" onblur="if(this.value==\'\') this.value=\'' . MODULE_BOXES_SEARCH_HEADER_BOX_INPUT . '\'" onfocus="if(this.value ==\'' . MODULE_BOXES_SEARCH_HEADER_BOX_INPUT . '\' ) this.value=\'\'"') . '' . tep_hide_session_id() . "
" .
        '           </div>' . "
" .
        '       <div id="smartsuggest" ></div> ' .
        '       </div>' . "
" . '</form>' . "
" .
        '</div>
                <script type="text/javascript">
        $(function(){
        var mq = window.matchMedia( "(max-width: 480px)" );
            if((mq.matches)) {
          $(".input-width").click(function() {
            $(this).animate({right: "0", width: "125px"}, 500);
          });
          $(".input-width input").blur(function(){
            $(this).parent().parent().animate({right: "0", width: "125px"}, 500);
          });
        }else{
          $(".input-width").click(function() {
            $(this).animate({right: "0", width: "360px"}, 500);
          });
          $(".input-width input").blur(function(){
            $(this).parent().parent().animate({right: "0", width: "190px"}, 500);
          });
        }

      });
                </script>
                ' . "
";

// MOD: BOF - SmartSuggest
if (SMARTSUGGEST_ENABLED != 'false') {
    require(DIR_WS_CLASSES . 'smartsuggest.php');
    $smartsuggest = new smartsuggest();
    $smartsuggest->output($data);
}
// MOD: EOF - SmartSuggest
  • 写回答

1条回答 默认 最新

  • douzhu7507 2016-04-05 13:11
    关注

    By using Jquery hide() and show() methods you can do this..Try ...)

    $(document).ready(function(){
        $("#hide").click(function(){
            $("p").hide();
        });
        $("#show").click(function(){
            $("p").show();
        });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <p>If you click on the "Hide" button, I will disappear.</p>
    
    <button id="hide">Hide</button>
    <button id="show">Show</button>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?