I am appending output to a ul element using li elements. I am able to generate the output as desired but I have no idea on how to use transitions and transform, as Javascript is creating those li elements.
I want to transform li elements as they appear from Javascript in the DOM.
Vanilla Javascript is preferred.
What I have, HTML:
<div class="add">
<input type="text" id="addTodoTextInput" placeholder="Add Task Here" onkeydown="handlers.addTodo()" > <!-- input text field to add <li> -->
<button onclick="search()"> <img src="add.png" height="20" width="20" alt=""> </button> <!-- button to add li -->
</div>
<ul class="result">
<!-- output generated with JavaScript will be appended here -->
</ul>
CSS:
li{
margin: 0 5px 0 5px;
padding: 5px;
font-family: cursive;
color: #006cff;
font-size: 1.3em;
background: rgba(43, 229, 43, 0.28);
transition: 2s;
}
li:hover{
transform: translateX(50px);
}
JavaScript:
var handlers = {
addTodo: function(){
var addToDoInput = document.getElementById('addTodoTextInput');
todoList.addToDo(addToDoInput.value);
addToDoInput.value = "";
view.displayTodo();
}
}
var view = {
displayTodo: function() {
var todosUl = document.querySelector('ul');
todosUl.innerHTML = '';
todoList.itemList.forEach(function(todo,position) {
var todosLi = document.createElement('li');
var todoTextWithCompletion = "";
if(todo.completed === true) {
todosLi.style.textDecoration = "line-through";
}
todosLi.id = position;
todosLi.textContent = todo.todoText;
todosLi.appendChild(this.createDeleteButton());
todosLi.appendChild(this.createToggleButton());
todosUl.appendChild(todosLi);
}, this);
}
}
I want to transform li tagsor you want us to transform your LI tagsI am appending my output to ul tag using li tagso why not just show that code here? So people willing to help can move on from there ... did you read How to create a Minimal, Complete, and Verifiable example?