作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我在这里找到的代码 http://www.w3resource.com/twitter-bootstrap/typehead.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Bootstrap typehead example by w3resource</title>
<link href="http://www.w3resource.com/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="well">
<input type="text" class="span3" style="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source='["Ahmedabad","Akola","Asansol","Aurangabad","Bangaluru","Baroda","Belgaon","Berhumpur","Calicut","Chennai","Chapra","Cherapunji"]'>
</div>
<script src="http://www.w3resource.com/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script src="http://www.w3resource.com/twitter-bootstrap/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
它正在工作,但我想在其中添加一个小功能。我想在列表中创建一个链接,该链接始终显示在列表底部。因此,如果您输入某些内容,则会过滤列表,但底部的链接始终会显示。
最佳答案
这个想法只是扩展 typehead 原型(prototype)来重新定义其渲染方法:
var uber = {render: $.fn.typeahead.Constructor.prototype.render};
$.extend($.fn.typeahead.Constructor.prototype, {
render: function(items) {
uber.render.call(this, items);
this.$menu.append('<li class="nostyle"><a href="#" onclick="alert(123)">some link</a></li>')
return this;
}
});
关于javascript - 始终在 Bootstrap 中预先输入的列表中显示链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13026585/
问了这个问题How to reach CSS zen? ,我现在明白我遇到的问题大多与定位有关。我发现一些文章说 CSS 作为布局系统并不总是足够好。 http://echochamber.me/vi
我是一名优秀的程序员,十分优秀!