![](/img/trans.png)
[英]how to limit the amount of data being sent by the client through websocket?
[英]How to limit the amount of some value being copied.
問題是我有一個JavaScript,可讓我的用戶設置一個值,說“ 0.6”,設置此值后,他們可以將其復制到我在javascript中指定的類ID。 問題是我想找出一種方法來限制此值,因此,可以說他們復制了該值,但只希望將其粘貼到前5個文本字段中,如何設置該值被粘貼多少次的限制,我對如何完成此操作感到困惑,因為我擁有的類ID可以具有任意數量的文本字段。 任何幫助將不勝感激!!!
這是我的帶有復制功能的JavaScript
$('.val_class').click(function() {
var txt;
var r = confirm("Are you sure you want to copy this value to each sample?.");
var text = $('.val_box').val();
if (r == true) {
$('.reading_class').val(text);
} else {
}
});
這是我的看法。
%th
%h2 Set a value to be copied to each sample.
%br
%tbody
%td
.js
%li Reading One
%br
=f.text_field :valc, :id => 'valc', :class => 'val_box', :hint => "You can set a value in this text box that will be copied to all of the samples, by pressing copy value button."
.control-group
.controls
%button{:type => "button", :class => 'val_class', :id => "val_class"}Copy this value to all samples(Reading One)
-@samples.each do |sample|
=number_field_tag "dimension[samples][#{sample.id}][value1]", sample.value_for_dim(@dimension, index+1), :id => 'reading', :class => 'reading_class', :step => "0.000001"
假設您有一個選擇器$('.my_class')
並且只想選擇其中的前5
個,只需執行以下操作:
$('.my_class').slice(0, 5).val(text)
有關.slice()
更多信息, .slice()
點擊此處
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.