簡體   English   中英

jQuery的每個淡入輸入框

[英]jquery each fadein input boxes

我想在輸入框中淡出給定的數字,如果我有5個數字,我想在5個輸入框中淡出。 有人可以幫忙嗎?

$('.submit').click(function(){
     var num = $('#num').val();

$.each(function() {
         $('.box').fadeIn('fast').html('<input type="text">');//I need five input boxes
      });
});

您的$.each()調用不正確。 嘗試簡單的for循環:

$('.submit').click(function(){
    var num = parseInt($('#num').val());
    var html = '';

    for (; num > 0; num--) {
        html += '<input type="text">';
    }

    $('.box').html(html).fadeIn('fast');
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM