jquery - Change Css Class of Same Id which is more than one Id with same name in html page -
i want change css class same id appear more 1 in page. try when there 2 id same name reflect first id not other.
i try:
view page : <i id="{{obj.id}}"></i>
controller
$(getjson.id).removeclass('busy b-white bottom');
$(getjson.id).addclass('on b-white bottom');
so, how can achieve ?
► first of id must unique.
when ever using id same name , try use class instead of that.
your solution
$('[id='+getjson.id+']').removeclass('busy b-white bottom').addclass('on b-white bottom');
this simple method tho select elements same id.
$('[id=test]').removeclass('yellow').addclass('red')
.yellow{ background-color:yellow; } .red{ background-color:red; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p id="test" class="yellow">q</p> <p id="test" class="yellow">w</p> <p id="test" class="yellow">e</p>
Comments
Post a Comment