300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > vue实现搜索框记录搜索历史_使用JS location实现搜索框历史记录功能_苏颜_前端开发者...

vue实现搜索框记录搜索历史_使用JS location实现搜索框历史记录功能_苏颜_前端开发者...

时间:2021-01-31 19:38:39

相关推荐

vue实现搜索框记录搜索历史_使用JS location实现搜索框历史记录功能_苏颜_前端开发者...

首先,来看下效果图(样式什么的就不必吐槽了哈)

搜索记录:

//用于保存记录信息

* {

margin: 0;

padding: 0;

}

input {

border: 0;

vertical-align: middle;

float: left;

}

#searchbox {

width: 300px;

height: 50px;

background: #fff;

margin: 100px auto;

border: 1px solid #ccc;

position: relative;

}

#inpt {

width: 240px;

height: 50px;

outline: none;

text-indent: 10px;

}

#btn {

width: 60px;

height: 50px;

cursor: pointer;

}

/* 历史记录框 */

#historybox {

width: 280px;

padding: 10px 10px 50px;

border: 1px solid #ccc;

position: absolute;

top: 50px;

left: -1px;

/* 隐藏 */

display: none;

}

#historybox h3 {

margin-bottom: 10px;

}

#list {

list-style: none;

}

#list .on {

float: left;

border: 1px solid #ccc;

background: #aaa;

height: 30px;

line-height: 30px;

margin: 0 2px;

border: 1px solid #ccc;

border-radius: 5px;

}

#list .active {

color: #fff;

text-decoration: none;

padding: 2px;

}

$(function () {

let max_history = 7;// 存储最大历史数据

// 鼠标移入事件

$('#inpt').on('focus', function () {

$('inpt').val = '';

let data = localStorage.getItem('data'); //从本地存储中读取数据

if (!data) {

$('#historybox').

总结

以上所述是小编给大家介绍的使用开发者网站的支持!

如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。