效果体验:http://hovertree.com/texiao/jquery/23/

代码如下,保存到HTML文件也可以查看效果:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
list-style: none;
} .search-hovertree-form {
width: 575px;
margin: 100px auto;
overflow: hidden;
} .search-hovertree-form .search-bd {
height: 25px;
} .search-hovertree-form .search-bd li {
font-size: 12px;
width: 60px;
height: 25px;
line-height: 25px;
text-align: center;
float: left;
cursor: pointer;
background-color: #eee;
color: #666;
} .search-hovertree-form .search-bd li.selected {
color: #fff;
font-weight: 700;
background-color: #B61D1D;
} .search-hovertree-form .search-hd {
height: 34px;
background-color: #B61D1D;
padding: 3px;
position: relative;
} .search-hovertree-form .search-hd .search-hovertree-input {
width: 490px;
height: 22px;
line-height: 22px;
padding: 6px 0;
background: none;
text-indent: 10px;
border: 0;
outline: none;
position: relative;
left: 3px;
top: 0;
z-index: 5;
#margin-left:-10px;
} .search-hovertree-form .search-hd .btn-search {
width: 70px;
height: 34px;
line-height: 34px;
position: absolute;
right: 3px;
top: 3px;
border: 0;
z-index: 6;
cursor: pointer;
font-size: 12px;
color: #fff;
font-weight: 700;
background: none;
outline: none;
} .search-hovertree-form .search-hd .pholder {
display: inline-block;
padding: 2px 0;
font-size: 12px;
color: #999;
position: absolute;
left: 13px;
top: 11px;
z-index: 4;
background: url(http://hovertree.com/texiao/jquery/23/images/zoom.jpg) no-repeat 0 0;
padding-left: 25px;
top:11px;
} .search-hovertree-form .search-hd .s2, .search-hovertree-form .search-hd #s2 {
display: none;
} .search-hovertree-form .search-bg {
width: 495px;
height: 34px;
background-color: #fff;
position: absolute;
left: 3px;
top: 3px;
z-index: 1;
}a{color:blue}
</style><meta charset="UTF-8">
<title> jQuery搜索切换 - 何问起</title><base target="_blank" />
</head>
<body> <div class="search-hovertree-form">
<div id="search-bd" class="search-bd">
<ul>
<li class="selected">找商品</li>
<li>找商家</li>
</ul>
</div>
<div id="search-hd" class="search-hd">
<div class="search-bg"></div>
<input type="text" id="s1" class="search-hovertree-input">
<input type="text" id="s2" class="search-hovertree-input">
<span class="s1 pholder">食品酒水半价抢疯</span>
<span class="s2 pholder">搜商家名称</span>
<button id="submit" class="btn-search" value="搜索">搜索</button>
</div>
</div>
<div style="text-align:center;clear:both;margin-top:10px">
<a href="http://hovertree.com/">首页</a> <a href="http://hovertree.com/texiao/">特效</a>
<a href="http://hovertree.com/menu/jquery/">jQuery</a>
<a href="http://hovertree.com/h/bjae/6no8y0fm.htm">原文</a>
<a href="http://hovertree.com/map/">导航</a>
</div>
<script type="text/javascript" src="http://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(function(){
//通用头部搜索切换
$('#search-hd .search-hovertree-input').on('input propertychange',function(){
var val = $(this).val();
if(val.length > 0){
$('#search-hd .pholder').hide(0);
}else{
var index = $('#search-bd li.selected').index();
$('#search-hd .pholder').eq(index).show().siblings('.pholder').hide(0);
}
})
$('#search-bd li').click(function(){
var index = $(this).index();
$('#search-hd .pholder').eq(index).show().siblings('.pholder').hide(0);
$('#search-hd .search-hover'+'tree-input').eq(index).show().siblings('.search-hovertree-input').hide(0);
$(this).addClass('selected').siblings().removeClass('selected');
$('#search-hd .search-hovertree-input').val('');
});
})
</script>
</body>
</html>

更多: http://www.cnblogs.com/jihua/p/webfront.html

jQuery带tab切换搜索框样式代码的更多相关文章

  1. 仿淘宝TAB切换搜索框

    <div class="search"> <div id="searchBox"> <ul class="tab-bar ...

  2. bootstrap搜索框样式代码及效果

    <div class="container"> <div class="input-group"> <input type=&qu ...

  3. jquery实现tab切换完整代码

    代码如下,保存到html文件打开: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  4. iOS开发UI篇 -- UISearchBar 属性、方法详解及应用(自定义搜索框样式)

    很多APP都会涉及到搜索框,苹果也为我们提供了默认的搜索框UISearchBar.但实际项目中我们通常需要更改系统默认搜索框的样式.为了实现这一目标,我们需要先搞懂 UISearchBar 的属性及方 ...

  5. easyui easyui-accordion的使用和在tab切换时没有样式

    1.easyui-accordion的使用 <div id="aa" class="easyui-accordion" style="width ...

  6. 好看css搜索框样式_分享8款纯CSS搜索框

    最简单实用的CSS3搜索框样式,纯CSS效果无需任何javascript,其中部分搜索框在点击的时候有动画特效,搜索框的应用也是比较普通的,效果如下: 设计网站大全https://www.wode00 ...

  7. JQuery实现tab切换

    JQuery实现tab切换: (jquery需要自己添加) <!DOCTYPE html> <html lang="en"> <head> &l ...

  8. 第二百一十节,jQuery EasyUI,SearchBox(搜索框)组件

    jQuery EasyUI,SearchBox(搜索框)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 SearchBox(搜索框)组件的使用方法,这个组 ...

  9. react 实现tab切换 三角形筛选样式

    ​ ​ 这次使用的是react的class 类组件 import React, { Component } from 'react' import { LeftOutline, SearchOutli ...

随机推荐

  1. SpringAOP之动态代理

    一.动态代理: 1.在原有的静态代理的基础上进一步的完善,由于静态代理中,重复写了相同的代码使得代码的整体结构显得冗余,而且还不同的核心类还需要有不用的代理类,是写死了的具体的类.所以需要使用动态代理 ...

  2. Distribution2:Distribution Writer

    Distribution Writer 调用Statement Delivery 存储过程,将Publication的改变同步到Subscriber中.查看Publication Properties ...

  3. 深入理解脚本化CSS系列第四篇——脚本化样式表

    × 目录 [1]CSSStyleSheet [2]CSSRule 前面的话 关于脚本化CSS,查询样式时,查询的是计算样式:设置单个样式时,设置的是行间样式:设置多个样式时,设置的是CSS类名.脚本化 ...

  4. 在 ML2 中配置 VXLAN - 每天5分钟玩转 OpenStack(110)

    上一节我们介绍了 VXLAN 的基本概念,今天介绍如何在 ML2 中启用 VXLAN. 在 /etc/neutron/plugins/ml2/ml2_conf.ini 设置 vxlan network ...

  5. 在ubuntu server中安装和配置docker

    经过一段时间针对不同版本的学习,现在总结当前最新的安装配置过程(应该也是比较简单的) 如果不清楚什么是docker,请参考 https://www.docker.com/ 准备工作 建议在安装之前运行 ...

  6. 【JavaWeb】MVC案例之新闻列表

    MVC案例之新闻列表 作者:白宁超 2016年6月6日15:26:30 摘要:本文主要针对javaweb基本开发之MVC案例的简单操作,里面涉及mysql数据库及表的创建,以及jsp页面和servle ...

  7. Oracle手边常用命令及操作语句

    Oracle手边常用命令及操作语句 作者:白宁超 时间:2016年3月4日11:24:08 摘要:日常使用oracle数据库过程中,常用脚本命令莫不是用户和密码.表空间.多表联合.执行语句等常规操作. ...

  8. Oracle客户端简易连接报错ORA-12154,TNS-03505

    环境: 服务端:RHEL6.5 + Oracle Server 11.2.0.4 客户端:Win2003 + Oracle Client 10.2.0.1 1.问题现象 2.Troubleshooti ...

  9. 1Z0-053 争议题目解析688

    1Z0-053 争议题目解析688 考试科目:1Z0-053 题库版本:V13.02 题库中原题为: 688.Which two statements are true about the compr ...

  10. 用HTML5 CANVAS做自定义路径的动态效果图片!

    最近对HTML5开始感兴趣了,实现的效果如下图,大家可以从代码里换掉图片 我用的是canvas里面的2d绘图,其中上图的路径是网上在线绘制的,我太懒了,哈哈 下面是网址: http://www.vic ...