【问题标题】:Trouble Retrieving Value with jQuery.val() and Modernizr Webshims Lib使用 jQuery.val() 和 Modernizr Webshims Lib 检索值时遇到问题
【发布时间】:2012-10-18 14:47:09
【问题描述】:

我正在使用 Modernizr plus Webshims 使我能够为尚不支持该选项的浏览器使用 type="number" 类型。它工作正常,但我无法使用 jQuery 访问数字输入字段的值 [我稍后会分享我正在使用的代码]。

在 Chrome(不需要 polyfill)中,我可以使用 val() 检索值。在 Firefox(确实需要 polyfill)中,如果我不使用 webshim polyfill,我也可以检索该值。

但是,一旦我使用了 webshim,我就无法再检索到该值。

这是我正在使用的代码:

在标签之前我有以下内容:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://localhost/bp2/wp-content/themes/method/custom/js/modernizr.custom.65840.js">      </script>
<script src="http://localhost/bp2/wp-content/themes/method/custom/js/webshims/polyfiller.js">   </script>
<script>
jQuery.webshims.polyfill('forms forms-ext');
jQuery(document).ready(function($) {
 $('select, input', window.parent.document).change(function() {
    var test = $('#test135').val();
    console.log(test135);
}).trigger('change');
});

</script>

在内容部分我添加了以下内容:

<input id="test" type="number" placeholder="Test2" max="360" min="0" step="30">

知道如何让它工作吗?

【问题讨论】:

    标签: html firefox modernizr polyfills shim


    【解决方案1】:

    这不应该是:

    console.log(test); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-05
      • 1970-01-01
      • 2019-12-24
      相关资源
      最近更新 更多