【问题标题】:jQuery MultiFile choose file buttonjQuery MultiFile 选择文件按钮
【发布时间】:2011-11-23 13:30:56
【问题描述】:

我使用 jQuery MultiFile 插件。下面的上传按钮:

我可以将 Choose File 文本更改为其他内容吗?网上冲浪帮不了我。

我只想要一个“选择文件”。

请说*是(+以及如何)或*否。

谢谢!

【问题讨论】:

标签: jquery html ruby-on-rails


【解决方案1】:

是的,我找到了最好的解决方法!这不是 hack - 我们只需要 2 个按钮:原始按钮和“假”按钮。

  <input type="button" value="Choose Files">
  <input type="file">

Fake 显示给用户,并且有

  z-index:1

原件位于其上方,带有

  z-index:2, opacity: 0; position: relative;

并且有回调:

  :onmousedown=>"buttonPush('depressed')", :onmouseup=>"buttonPush('normal')"

  function buttonPush(buttonStatus) {
    if (buttonStatus == "depressed")
      document.getElementById("fake_btn").style.borderStyle = "inset";
    else
      document.getElementById("fake_btn").style.borderStyle = "outset";
  }

感谢此链接 http://www.dreamincode.net/forums/topic/15621-styling-a-file-browse-button/

问候@Piskvor,@racar

【讨论】:

  • 你摇滚!将 style="visibility:hidden" 添加到文件按钮,你就很成功了。
【解决方案2】:

不,这是&lt;input type="file"&gt;控件的一部分,网页无法控制其外观。

【讨论】:

  • @racar:这确实是一个 hack - 一个相当丑陋的 hack,恕我直言;它会被标记为点击劫持(因为它是良性的):gnucitizen.org/blog/… 不过,感谢您指出重复项。
  • 我明白了。我可以隐藏文件控件,并通过 jquery/javascript '激活'它吗?
  • 我同意,但这不是我的选择
  • @racar:我不是说它是 :) OTOH,添加一段会触发严重警告消息的代码(目前在 IE9 和 FF+NoScript 中)听起来不太友好对我来说。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-17
  • 1970-01-01
  • 1970-01-01
  • 2013-10-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多