0

このフォームがあります。メモ帳を開くと、リンクのリストが表示されます。メモ帳からコピーして、テキストエリアにすべてのリンクを貼り付けると、カウントされます。

しかし、私が解決しようとしているのは、コピーして貼り付けると、入力したときに自動的にカウントされないということです。

私のコードは、私の作品を説明するために以下にあります。

jQueryコード

jQuery.fn.wordCount = function(params) {
    var p =  { counterElement:"display_count" };
    var total_words;

    if(params) {
        jQuery.extend(p, params);
    }

    //for each keypress function on text areas
    this.keypress(function() {
        total_words=this.value.split("\n").length;
        jQuery('#'+p.counterElement).html(total_words);
    });
};

$(document).ready(function(){                           
    $('#txtLinks').wordCount();
});

私のフォーム

<form method="post">
<textarea name="texturl" rows="10" cols="20" id="txtLinks" class="textarea-addlinks"></textarea>
</form>

とリンクは

http://09-flex-actionscript-it.gnstudio.com/index.php?title=Are_aware_of_the_Uncomplicated_strategies_to_post_sms_to_help_all_people
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Below_To_acquire_pizza_hut_vouchers
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Brand-new_business_model_innovation_specialists
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Ery_at_times_a_good_Pizza_Express_Voucher_Are_usually_for_exciting
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Gain_knowledge_of_on_the_subject_of_signs_of_depression
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Get_yourself_a_dvd_swimming_pool_covers_currently
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Simple_and_standard_symptoms_of_the_flu
http://09-flex-actionscript-it.gnstudio.com/index.php?title=Speaking_about_the_necessities_regarding_tinnitus_miracle:
http://09-flex-actionscript-it.gnstudio.com/index.php?title=The_best_places_to_secure_cheap_supplements_web_based

カウント値は9である必要があります。Enterキーを押す必要がない方法はありますか?つまり、リンクが自動的にカウントされますか?ちなみに-それはどのように数えますか?それはさようなら新しいリンクを数えます。

みんなありがとう

4

1 に答える 1

1

これはうまくいくようです:http://jsfiddle.net/js7Qn/

私が使用した:

$('#txtLinks').keyup(...
于 2012-09-07T14:47:43.653 に答える