English 中文(简体)
限制项目在开放时以超文本递减清单列报
原标题:limit the items to show in HTML drop down list when it opens

我有10个项目在下降,只想首先显示5个项目,而其余项目则保留在滚动中。

我有以下代码控制<代码>的大小。 JS。

$(function(){
  $("#myList").click(function(){
    $(this).attr( size ,  5 );
  });
});

在<代码>上确定如下内容:

<select size="5">
  <option value=""></option>
  ...
</select>

由于违约,每当有5个项目时,就将减少,浏览器可自行处理,从而考虑通过<代码>JS进行。

problem,其中5项物品开张,但并不像正常下降一样自动关闭,直到网页复读(明显)。 请提出咨询意见。

最佳回答

您可以修改名单,以显示多个项目,然后只显示所选择的去向:

$(document).ready(function(){

$("#mylist").hover(function(){

$(this).attr( size ,  5 );
},function(){
 $(this).removeAttr("size");   
});

});​

rel=“nofollow>>>>>strong>- SEE DEMO --

问题回答

然而,被接受的解决办法只是罚款,而只是在1.9>/strong>之前的j Query版本,因为>hover从此以后从该文本中删除了

但您可使用<代码>hover()和其他经解释的特征,使用

<代码>jQuery, i.e. v1.9 +

$(function(){
  $("#myList").on({
    mousedown: function(){
      $(this).attr( size ,  5 );
    },

    mouseleave: function(){
      $(this).removeAttr( size );
    }
  });
});

这里是working DEMO





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签