English 中文(简体)
jQuery 中带有输入框的动态表格排序
原标题:Sorting Dynamic Tables With Input Boxes in jQuery

我用jsFiddle演示了我想在这里做的事:http://jsfiddle.net/clowerweb/SbNdb/

只需点击表格页眉来排序( 您可能需要点击一次以上!)

因此,我这里有一个动态表格,用来增删竞争者,他们可以有不同数目的条目(同样,它也可以保存,并且随机选择一个赢家)。

我想输入参赛者的用户可能也希望能够按字母顺序排序列表,或者按条目数量排序。 我在 SO 上找到一个漂亮的表格排序脚本, 并将其添加到我的 jQuery 函数中 。

问题 is , 它似乎没有读取输入值。 它会将表格的顺序两边颠倒, 并恢复到默认状态, 但实际上不会通过输入值来< strong > sort 它们 。

可能有两个问题: " 强 " / " 强 " 。

  1. most likely is that it s simply not reading the input values.
  2. It could also not be able to actually see the dynamically added rows (although it looks like it loops through the table on click, so I don t suspect that as the issue.)

任何帮助都非常感激和感谢!

最佳回答

您在 比较函数 中正在获取的功能 是 td , 所以要根据 input 进行排序, 您需要在 td 中搜索这些功能, 并与 text field s value 进行比较。 因此, 比较函数将看起来像 。

function(a, b) {                
   return $(a).find( input ).val() > $(b).find( input ).val() ?
                 inverse ? -1 : 1
                : inverse ? 1 : -1;
}

"http://jsfiddle.net/joycse06/MwxXj/5" rel="nofollow" >Working Fiddle

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签