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 :'';
});