TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dip vyas
NA
227
38.2k
how to click to add parent class in javascript??
Jun 10 2019 1:53 AM
i use dynamically add li when i type in inputbox..it automatically add but when i close to close button in li it not working...
here is my code
<div
class
=
"to-do"
>
<input type=
"text"
id=
"candidate"
/>
<button onclick=
"addItem()"
>add</button>
<ul id=
"dynamic-list"
></ul>
</div>
<script>
function
addItem(){
var
ul = document.getElementById(
"dynamic-list"
);
var
candidate = document.getElementById(
"candidate"
);
var
li = document.createElement(
"li"
);
li.setAttribute(
'id'
,candidate.value);
li.appendChild(document.createTextNode(candidate.value));
ul.appendChild(li);
var
button = document.createElement(
"button"
);
li.appendChild(button);
button.classList.add(
"mystyle"
);
}
</script>
Reply
Answers (
3
)
Web API with HTTPs
Dropdownlist select item text overflow outside and icon set