How to add a class to html tag?

I have an HTML code like

<div class="class1 class2">
  <ul><li class="class1"></li></ul>

Here the div tag and the li tag have same class name, I just want to add another class to the li tag that have the class class1. How can I do this?

Answers 1

  • First of all your markup is not valid

    The HTML <li> element (or HTML List Item Element) is used to represent an item in a list. It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>). ( Taken from : )

    You can add class by using addClass()

    <script src=""></script>
    <div class="class1">
      <ul><li class="class1"></li></ul>

Related Articles