Loading...
Есть код

$(document).ready(function() {
$('#stepw').click(function() {
var url = $(this).attr('href');

$.ajax({
url: url + '?ajax=1',
success: function(data){
$('#content').html(data);
}
});

// А вот так просто меняется ссылка
if(url != window.location){
window.history.pushState(null, null, url);
}

// Предотвращаем дефолтное поведение
return false;
});
});


есть html код

echo '<div style="float: right; margin: -100px 0px 0px 0px; padding: 1px; opacity: 0.9; background: #000;
border-radius: 45px 0px 0px 45px;
"><center><a id="stepw" href="/map/top/"><img src="/images/top.png" alt=""></a> <br><a id="stepw" href="/map/left/"><img src="/images/left.png" alt=""> <a id="stepw" href="/map/right/"><img src="/images/right.png" alt=""> <br><a id="stepw" href="/map/bottom/"><img src="/images/bottom.png" alt=""></a> </center></div>';


Как сделать что бы jqery работал для всех а с id=stepw ?
Wap[Crafter] ,
Ну так у тебя в коде определённое значения для идентификатора заданно.
Сделай блок, допустим div
И внесли в функцию Query не #идентификатор, а полностью ("div")
444113352 , а код можно?
Wap[Crafter] ,

html


echo '<div style="float: right; margin: -100px 0px 0px 0px; padding: 1px; opacity: 0.9; background: #000; border-radius: 45px 0px 0px 45px; text-align: center;"><a id="stepw_top" href="/map/top/"><img src="/images/top.png" alt=""></a> <br><a id="stepw_left" href="/map/left/"><img src="/images/left.png" alt=""> <a id="stepw_right" href="/map/right/"><img src="/images/right.png" alt=""> <br><a id="stepw_bottom" href="/map/bottom/"><img src="/images/bottom.png" alt=""></a></div>';


javascript


$(document).ready(function () {
$('#stepw_top, #stepw_left, #stepw_right, #stepw_bottom').click(function () {
var url = $(this).attr('href');
$.ajax({
url: url + '?ajax=1',
success: function (data) {
$('#content').html(data);
}
});
if (url != window.location) {
window.history.pushState(null, null, url);
}
return false;
});
});
Онлайн: 1
Время:
Gen. 0.075
(c) Bym.Guru 2010-2026