html - how to replace data("id") in jquery -
html - how to replace data("id") in jquery -
i had nestable want alter
data-id="12"
to
may max data-id equals 17
and want alter data-id value
data-id="39"
here code: class="snippet-code-html lang-html prettyprint-override"><!--before--> <div class="dd" id="nestable"> <ol class="dd-list" id="depth1_ol"> <li data-id="12"><div class="dd-item">item 12</div></li> </ol> </div> <!--after--> <div class="dd" id="nestable"> <ol class="dd-list" id="depth1_ol"> <li data-id="39"><div class="dd-item">item 39....</div></li> </ol> </div>
how can this??
your question bit unclear i'm assuming need alter data-id
attribute. well, alter value using jquery can using data
method below...
$("li").data("id", "39");
however, aware not alter actual dom element, stored in memory farther manipulation within jquery framework. if you want alter dom directly, utilize attr
method below...
$("li").attr("data-id", "39");
jquery html
Comments
Post a Comment