File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -82,3 +82,24 @@ const listLight = document.querySelectorAll('li:nth-child(odd'); //get all query
82
82
listLight . forEach ( function ( li , index ) {
83
83
li . style . background = '#ccc' ;
84
84
} )
85
+
86
+ // ## create new element ##
87
+ const li = document . createElement ( 'li' ) ;
88
+
89
+ // ### add class ###
90
+ li . className = 'list-group-item d-flex flex-row-reverse justify-content-between' ;
91
+
92
+ // ### add id ###
93
+ li . id = 'new-item'
94
+
95
+ // ### add attribute ###
96
+ li . setAttribute ( 'title' , 'new item' )
97
+
98
+ // ### add innerHTML ###
99
+ li . innerHTML = '<a href="/" class="btn btn-danger btn-sm delete-item">x</a>' ;
100
+
101
+ // Create append text node
102
+ li . appendChild ( document . createTextNode ( "This New Text" ) )
103
+
104
+ // execution new element
105
+ document . querySelector ( 'ul.list-group' ) . appendChild ( li ) ;
You can’t perform that action at this time.
0 commit comments