Просмотр полной версии : jQuery странное поведение в IE6
Делаю подсветку (замену) картинок при наведении...
Но IE6 ведет себя странно...
Вот пример:
http://crystals.ru/rus/company/clients_new/
Тут для теста сделано по-другому - просто картинка заменяется текстом. Но в IE почему-то не заменяет а добавляет перед картинкой... хотя у меня replaceWith()
monolithed
10.11.2010, 18:43
Что мешает сделать так?:
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<style type="text/css">
div {padding-top: 27px; text-align: center; width: 218px; height: 48px;}
</style>
<script type="text/javascript">
$(function(){
$('div').hover(function(){
$(this).html($('img', this).attr('alt')).end().hide();
});
});
</script>
<div>
<img src="http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif" alt="image" />
</div>
Мне не совсем это нужно... суть в том что при изменении attr('src', 'новое значение') IE6 не меняет картинку... в других браузерах работает нормально...
monolithed
11.11.2010, 14:22
Ок, тогда почему у вас текст заместо изображения появляется?
Думаю, что это решение подойдет:
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function(){
var image = ['http://www.sanstream.co.jp/player/img/logoApple.jpg', 'http://www.sanstream.co.jp/player/img/logofirefox.jpg'];
$('img').each(function(i){
$(this).bind({
mouseover: function(){
$(this).attr('rel', $(this).attr('src')).attr('src', image[i]);
},
mouseout: function(){
$(this).attr('src', $(this).attr('rel'));
}
});
});
});
</script>
<img src="http://www.sanstream.co.jp/player/img/logoWinVista.jpg" alt="" />
<img src="http://www.sanstream.co.jp/player/img/logoWinXP.jpg" alt="" />
Спасибо. Текст появлялся для тестирования.
Проблему уже решил другим способом. Еще быстрее по производительности.
vBulletin® v3.6.7, Copyright ©2000-2025, Jelsoft Enterprises Ltd. Перевод: zCarot