$elem.on('keydown', function(e) {
if (e.keyCode == 27) {
//...
}
});
var id = $(this).attr('id').substring(8);
var last_id = $('#answer_pid' + id + ' li:first div').attr('id').substr(7);
<div class="comment" id="comment_123"></div>
var id = $(this).attr('id').substring("comment_".length);
<div class="comment" data-id="123"></div>
var id = $(this).attr('data-id');
var id = $(this).data('id');
$.post(url, data, function(data) {
data = $.parseJSON(data);
//...
});
$.post(url, data, function(data) {
try {
data = $.parseJSON(data);
} catch (e) {
return;
}
//...
});
$.post(url, data, function(data) {
//...
}, 'json');
$.post(url, data, function(data) {
//...
}, 'json').error(function() {
///
});
$.ajaxSetup({
error: function() {
// ,
}
});
$.ajax({
type: "POST"
url: url,
data: data,
dataType: "json",
success: function(data) {
//
},
error: function() {
//
}
});
$('.comment a.delete').click(function(){
//
});
$('.comment a.delete').unbind('click').click(function() {
//
});
$('body').on('click', 'a.external', function(e) {
// external
});
$('body').on('mousemove', selector, function() {
//
});
$('a').on('click', function() {
// 1
});
$('a').on('click', function() {
// 2
});
$('a').on('click.namespace1', function() {
// 1
});
$('a').on('click.namespace2', function() {
// 2
});
Source: https://habr.com/ru/post/149237/
All Articles