我有这个表格,当我打开记事本时,会有我的链接列表,我从记事本复制它,然后将所有链接粘贴到 textarea 中,然后它应该计数。
但我试图解决的是,当我复制和粘贴时,它会在我输入时自动计数。
我的代码在下面解释我的作品。
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。有什么方法不需要按回车我的意思是它会自动计算链接?顺便说一句——它是如何计算的?它算再见新链接。
多谢你们