我有一堆元素(Div),它们都表示项。通过Ajax,我可以单击链接来删除它们,并把div值存储在id中。但我想要id名称以标准的字母开头。因此,我需要以另一种方式存储值。
有什么方法可以用html存储值?我正在重新思考什么是存储价值的好方法。
You can store it as text inside the div if you like. You also can use inputs, just add the form tag around everything. Just because it's a form doesn't mean it has to "submit". Inputs or textboxes would probably be the best way to store them actually.
Best way is to use the new HTML 5 spec to store data in the data-[name] in the div elements
ie
<div data-yourfield="value">
Text
</div>
Then using jQuery find the divs with the selector (reference http://api.jquery.com/category/selectors/)
div[data-yourField=""]