Подскажите как подставить значение переменной в width и height
$(document).ready(function() {
var cont_left = $(".image_block").position().left;
$("a .jshop_img").hover(function() {
// приближение
$(this).parent().parent().css("z-index", 1);
$(this).animate({
height: "300",
width: "250",
left: "-=50",
top: "-=50"
}, "fast");
}, function() {
// отдаление
$(this).parent().parent().css("z-index", 0);
$(this).animate({
height: "150",
width: "150",
left: "+=50",
top: "+=50"
}, "fast");
});
$(".img").each(function(index) {
var left = (index * 160) + cont_left;
$(this).css("left", left + "px");
});
});
|
$(document).ready(function() {
var cont_left = $(".image_block").position().left;
$("a .jshop_img").hover(function() {
// приближение
$(this).parent().parent().css("z-index", 1);
$(this).animate({
height: "300",<----СЮДА
width: "250",<-----И СЮДА
Хочу определетиль изначальный размер картинки и умножить значения width и height на 2, а потом присвоить получившиеся значения в width и height. Как реализовать подскажите? |
Цитата:
var h=600;
var w=500;
$(this).animate({
height: h, //<----СЮДА
width: w, //<-----И СЮДА
|
Цитата:
|
Цитата:
<img src='http://javascript.ru/forum/images/smilies/smile.gif' />
<script type="text/javascript">
var o=document.getElementsByTagName('img')[0];
alert(o.clientWidth+'x'+o.clientHeight);
</script>
|
Цитата:
|
$(document).ready(function() {
var cont_left = $(".image_block").position().left;
$("a .jshop_img").hover(function() {
// приближение
$(this).parent().parent().css("z-index", 1);
$(this).animate({
var h = ...//как то получить height картинки
var w = ...//как то получить width картинки
height: h * 2,
width: w * 2,
left: "-=50",
top: "-=50"
}, "fast");
}, function() {
// отдаление
$(this).parent().parent().css("z-index", 0);
$(this).animate({
height: "150",
width: "150",
left: "+=50",
top: "+=50"
}, "fast");
});
$(".img").each(function(index) {
var left = (index * 160) + cont_left;
$(this).css("left", left + "px");
});
})
Как то так мне нужно. Картинок много и они разных размеров, поэтому src не знаю как прописать, сайт на joomla и картинки это товары интернет магазина, которые выводятся из бд. |
Цитата:
|
Цитата:
$(document).ready(function() {
var cont_left = $(".image_block").position().left;
$("a .jshop_img").hover(function() {
var h = $(this).height();
var w = $(this).width();
// приближение
$(this).parent().parent().css("z-index", 1);
$(this).animate({
height: h * 2,
width: w * 2,
left: "-=50",
top: "-=50"
}, "fast");
}, function() {
// отдаление
$(this).parent().parent().css("z-index", 0);
$(this).animate({
height: "150",
width: "150",
left: "+=50",
top: "+=50"
}, "fast");
});
$(".img").each(function(index) {
var left = (index * 160) + cont_left;
$(this).css("left", left + "px");
});
})
Вот что я хотел. Все работает. |
| Часовой пояс GMT +3, время: 14:42. |