简体   繁体   English

在jQuery中迭代重力形式的可重复列表

[英]Iterating Gravity Forms Repeatable Lists in jQuery

This question is a bit specific to Gravity Forms, but it is a common issue found in web development with jQuery. 这个问题是Gravity Forms特有的,但这是使用jQuery进行Web开发时常见的问题。

Gravity Forms allows you to use repeatable lists: http://www.gravityhelp.com/documentation/page/Gform_column_input_content 重力表单允许您使用可重复的列表: http : //www.gravityhelp.com/documentation/page/Gform_column_input_content

These are essentially just fields which give the +/- to be added/removed which I'm assuming they just get cloned. 这些基本上只是字段,这些字段给出了要添加/删除的+/-,我假设它们只是被克隆了。

What I am trying to do is have a Number next to each one (First field says 1. [field], Second: 2. [field] and so forth.) 我想做的是在每个数字旁边都放一个数字(第一个字段说1. [field],第二个字段说2. [field],依此类推。)

My code: 我的代码:

$.each($(".gfield_list input"), function(index,elem) {
    $("<span>"+(index+1)+". </span>").prependTo($(this).parent());
})

Which is then hooked to the on("click", function() {}), however is not producing the desired results. 然后将其挂接到on(“ click”,function(){})上,但是未产生期望的结果。

If anyone could help, this would be greatly appreciated. 如果有人可以帮助,将不胜感激。

Thanks, 谢谢,

Here's an alternate solution that uses CSS rather than jQuery. 这是使用CSS而不是jQuery的替代解决方案。

http://gravitywiz.com/numbering-gravity-forms-list-field-rows/ http://gravitywiz.com/numbering-gravity-forms-list-field-rows/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM