search

Home  >  Q&A  >  body text

angular.js - In angularjs, select the checkbox and add a classname to its upper level, uncheck to remove the classname

When the check box is selected, a classname is added to li. When it is deselected, the classname of li is removed
I’ve been searching for a long time but haven’t found a good way to operate the dom

巴扎黑巴扎黑2787 days ago780

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 16:55:17

    Use ng-class
    ng-class="{'className':value}"
    When value is true, className style will be applied

    reply
    0
  • 为情所困

    为情所困2017-05-15 16:55:17

    If you use class,最好给li一个ng-class,<li ng-class="{true: 'clasname'}[checked == true]" ></li>~

    reply
    0
  • Cancelreply