Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function attachEvents() {
- let input = '';
- $('#btnDelete').click(function () {
- let message = '';
- input = $('#townName').val();
- let towns = $('#towns option');
- for (let town of towns) {
- if (town.text === input) {
- $(`#towns option:contains(${input})`).remove();
- message = `${input} deleted.`;
- break;
- }
- message = `${input} not found.`;
- }
- $('#result').text(message);
- $('#townName').val('');
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement