Tag: dom manipulation

根据选定的OPTION宽度自动调整SELECT元素的大小

我有这个select元素与不同的option 。 通常, select元素将从最大的option元素中获取宽度,但我希望select元素具有较短的默认option值宽度。 当用户select另一个option , select元素应该调整自己的大小,使得整个文本始终在元素中可见。 $(document).ready(function() { $('select').change(function(){ $(this).width($('select option:selected').width()); }); }); 问题: 在Chrome(金丝雀)它总是得到一个宽度返回0。 在Firefox上,宽度get被添加,并且在select较短的选项时不被resize。 Safari:与Chrome相同。 演示@ JSFiddle

在input中对ng模型进行过滤

我有一个文本input,我不想让用户使用空格,input的东西都会变成小写。 我知道我不允许在ng-model上使用filter。 ng-model='tags | lowercase | no_spaces' 我看着创build我自己的指令,但添加函数到$parsers和$formatters没有更新input,只有其他ng-model元素。 我怎样才能改变我正在input的input? 我基本上试图创build“标签”function,就像在StackOverflow这里的工作。