javascript - How to increment div id value? -
i have got task set menu selected. use dynamic id. want increment respect selection
my code is
<div class="menuheader ui-corner-top" id="menu"+ i> <span><a href="#" onclick="home()">home</a></span> </div> <div class="menuheader ui-corner-top" id="menu"+ i> <span><a href="#" onclick="newtransaction()">new transaction</a></span> </div> <div class="menuheader ui-corner-top" id="menu"+ i> <span><a href="#" onclick="portfolio()">portfolio</a></span> </div>
javascript is
$(document).ready(function () { alert(document.url); var list = $("#menu"); (var = 1; <= list.length; i++) { list[i].innerhtml = i; } var str = document.url.tolowercase().indexof("portfolio/index"); alert(str); if (str >= 0) { $('#menu').addclass("menuheaderactive"); } });
how can this?
var i=0; $('.menuheader').each(function(){ i++; var newid='menu'+i; $(this).attr('id',newid); $(this).val(i); });
Comments
Post a Comment