如何在jquery或javascript中获取动态创建的文本框值

时间:2015-07-09 04:26:13

标签: jquery

@font-face {
    font-family: 'myfont';
    src:url('fonts/myfont.eot?-td2xif');
    src:url('fonts/myfont.eot?#iefix-td2xif') format('embedded-opentype'),
        url('fonts/myfont.woff?-td2xif') format('woff'),
        url('fonts/myfont.ttf?-td2xif') format('truetype'),
        url('fonts/myfont.svg?-td2xif#myfont') format('svg');
    // Different URLs are required for optimal browser support
    // Make sure to :
    // 1) replace the URLs with your font's URLs
    // 2) replace `#myfont` with the name of your font
    font-weight: normal; // To avoid the font inherits boldness
    font-style: normal; // To avoid font inherits obliqueness or italic
}

.emoji {
    font-family: 'myfont', Verdana, Arial, sans-serif; // Use regular fonts as fallback
    speak: none; // To avoid screen readers trying to read the content
    font-style: normal; // To avoid font inherits obliqueness or italic
    font-weight: normal; // To avoid the font inherits boldness
    font-variant: normal; // To avoid the font inherits small-caps
    text-transform: none; // To avoid the font inherits capitalization/uppercase/lowercase
    line-height: 1; // To avoid the font inherits an undesired line-height
    -webkit-font-smoothing: antialiased; // For improved readability on Webkit
    -moz-osx-font-smoothing: grayscale; // For improved readability on OSX + Mozilla
}

3 个答案:

答案 0 :(得分:1)

HTML中的

: -

<input type='text' class='product' name='product_" + i + "' id='product_" + i + "'/>

并在jQuery中: -

 $('.product').each(function() {
           var product =  $(this).val();
           alert(product);
         });

答案 1 :(得分:0)

而不是

$('input[name="product_' + i + '"]').val()

尝试:

$('body').find('input[name="product_' + i + '"]').val()

答案 2 :(得分:0)

尝试使用选择器启动...

$("input[name^='product_']").each(function() {
       var textVal =  $(this).val();
       alert(textVal);
     });