Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript-更改每个循环中的html元素_Javascript_Jquery_Ruby On Rails 4 - Fatal编程技术网

Javascript-更改每个循环中的html元素

Javascript-更改每个循环中的html元素,javascript,jquery,ruby-on-rails-4,Javascript,Jquery,Ruby On Rails 4,愚蠢的问题,我肯定,但我不知道答案 我用这种方式填充了一个字段 <div class="field"> <%f.label :client_id %> <%= f.select :client_id, options_for_select(Client.all.map{ |p| [p.appointment_record, p.id]}), # your options for this select box include_blank: '

愚蠢的问题,我肯定,但我不知道答案

我用这种方式填充了一个字段

<div class="field">
<%f.label :client_id %>
<%= f.select :client_id,
      options_for_select(Client.all.map{ |p| [p.appointment_record, p.id]}), # your options for this select box
      include_blank: 'Select Client'
%>
它是

请先选择患者
盖伊,第一程序员
盖伊,第二个代码猴子
我想要的是更改那些值标记。此列表是动态生成的


如何更改.each循环中的值标记以使其保持不变?

根本不清楚要更改什么或从什么来源更改

假设您想要更改
值,您可以使用在集合中循环。函数的参数是索引和当前值

例如:

$('#appointment_client_id').children(':gt(0)').val(function(i, currVal){
    return currVal ? currVal * 10 :'';
});

我刚刚为您添加了jQuery标记,请为您在HTML中使用的其他语言添加另一个标记(它是液体吗?)。谢谢当然该程序是在RubyonRails中,如果你正在寻找的话!谢谢现在,您已经用它标记了您的问题,了解RubyonRails的人将能够找到它!解释不够详细。需要更具体地说明要更改的内容以及新值的来源。显示基于当前示例的预期结果
<option value="">Select Patient First, Please</option>
<option value="1">Guy, First - Programmer</option>
<option value="2">Guy, Second - Code Monkey</option>
$('#appointment_client_id').children(':gt(0)').val(function(i, currVal){
    return currVal ? currVal * 10 :'';
});