【问题标题】:focus select html element using jquery [duplicate]使用jquery聚焦选择html元素[重复]
【发布时间】:2016-04-20 14:42:30
【问题描述】:

如何使用 JS 提示原生 select 元素?

http://jsfiddle.net/dqa0p30q/

$('#img').click(function() {
  alert('');
  $('select').trigger('change');
  $('select').focus()// this won't work too
})

【问题讨论】:

  • 你触发的改变在哪里?
  • 检查demo

标签: javascript jquery


【解决方案1】:

你可以这样做:

$('#img').click(function() {
  alert('');
  $('select').trigger('change');
  $('select').focus()
  selectbox = $('select')[0]
  selectbox.size = selectbox.options.length;
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 2014-10-09
    • 2015-01-17
    • 2017-08-11
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    相关资源
    最近更新 更多