I have a html page with multiple similar elements which can be edited in-place:
The Title
Some description
Count 10
[Edit]
Another Title
Another description
Count 54
[Edit]
...
如果ed子被点击,则案文用Ajax的表格取而代之(该网页的其余部分被重载):
Title: [The Title ]
Description: [Some description]
Count: [10]
[Save] [Cancel]
Another Title
Another description
Count 54
[Edit]
...
The event handlers to replace the text with a form and to submit the form are almost identical for all items. My first approach was to use IDs in the html tags and bind the jQuery event handler to this ID. But hat leads to repetitive code. So the obvious idea is to not repeat similar code for each item.
我怎么能够区分手里的物品,以便用表格取代正确的项目,并提交正确的表格?