Skip to content

Instantly share code, notes, and snippets.

@bbagno
Created November 11, 2017 23:33
Show Gist options
  • Save bbagno/8f7301cf92fe322ffc70e9a4cd620930 to your computer and use it in GitHub Desktop.
Save bbagno/8f7301cf92fe322ffc70e9a4cd620930 to your computer and use it in GitHub Desktop.
app.js
var guid = function() {
var s4 = function() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4();
}
var add_li = function(task_text) {
var li_id = guid();
$('#mainul').append(
'<li id="' + li_id + '">' +
'<span>' + task_text + '</span>' +
'<input type="button" onclick="$(\'#' + li_id + '\').remove()">' +
'</li>'
)
}
$(document).ready(function() {
$('#root').append(
'<ul id="mainul"></ul>' +
'<hr>' +
'<input id="add_task_input">' +
'<input type="button" id="add_task" onclick="add_li($(\'#add_task_input\').val())">'
)
add_li("Сделать задание #3 по web-программированию")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment