Я посмотрел другие посты и их решения не помогли.
Мой HTML-код:
<div class="btn-group">
<button type="button" class="btn btn-default 1">1</button>
<button type="button" class="btn btn-default 3">3</button>
</div>
<div class="grid-item grid-item-double-height item-1" data-button-type="interior">
<a href="#">
<img src="img/lazyload-ph.png" data-src="img/slurp-004.jpg" class="img-responsive lazyload"/>
</a>
</div>
И я попробовал следующий jquery:
$(".btn-group").on('click', 'button', function(e) {
var push = $(this).data("button-type");
alert(push);
});
и
$(".btn-group").on('click', function(e) {
var push = $(this).data("button-type");
alert(push);
});
и
$(".btn-group").on('click', 'button', function(e) {
var push = $(this).attr("data-button-type");
alert(push);
});
, и я попробовал этот последний, потому что я прочитал, что использование «this» относится к самому внешнему элементу
$("buttn").on('click', function(e) {
var push = $(this).data("button-type");
alert(push);
});
и
$(".btn").on('click', function(e) {
var push = $(this).data("button-type");
alert(push);
});
Я также пробовал без "е", как в:
function(e) {
стал
function() {
В каждом случае яполучить "неопределенный".Из всех моих исследований я не могу понять, в чем проблема.
Спасибо, Ричард Белотт