admin管理员组文章数量:1295899
I would like to show tooltip when input.val().length <= 3
then hide tooltip when > 3 chars
Check this out:
<input type="text" id="nav-search"/>
$('#nav-search').on('keyup',function(){
var _keys = $(this).val();
if(_keys.length <= 3){
$(this).tooltip({'trigger':'focus',position:'right'});
$(this).trigger('focusin');
}
});
it doesn't works obviously :/
I would like to show tooltip when input.val().length <= 3
then hide tooltip when > 3 chars
Check this out:
<input type="text" id="nav-search"/>
$('#nav-search').on('keyup',function(){
var _keys = $(this).val();
if(_keys.length <= 3){
$(this).tooltip({'trigger':'focus',position:'right'});
$(this).trigger('focusin');
}
});
it doesn't works obviously :/
Share Improve this question edited Sep 25, 2012 at 14:51 Florent 12.4k10 gold badges50 silver badges58 bronze badges asked Sep 25, 2012 at 10:30 Filippo orettiFilippo oretti 49.9k96 gold badges229 silver badges351 bronze badges2 Answers
Reset to default 8Theoretically, it should work:
$("#nav-search").on("keyup", function() {
if (this.value.length <= 3) {
$(this).tooltip("show");
} else {
$(this).tooltip("hide");
}
}).tooltip({
placement: "right",
trigger: "focus"
});
Practically, it works.
DEMO: http://jsfiddle/FvxnN/
$('#nav-search').bind('keyup',function(){
var _keys = $(this).val();
if(_keys.length <= 3){
$(this).tooltip({'trigger':'focus',position:'right'});
$(this).trigger('focusin');
}else{
//perform some action
}
});
本文标签: javascriptBOOTSTRAP trigger tooltip on input element only if input val length lt nStack Overflow
版权声明:本文标题:javascript - BOOTSTRAP trigger tooltip on input element only if input val length < n - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741627427a2389165.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论