Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   jQuery странное поведение в IE6 (https://javascript.ru/forum/jquery/12958-jquery-strannoe-povedenie-v-ie6.html)

APL 10.11.2010 15:59

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>

APL 11.11.2010 12:31

Мне не совсем это нужно... суть в том что при изменении 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="" />

APL 12.11.2010 02:19

Спасибо. Текст появлялся для тестирования.
Проблему уже решил другим способом. Еще быстрее по производительности.


Часовой пояс GMT +3, время: 11:54.