Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Сдвиг картинки-ссылки (https://javascript.ru/forum/misc/23374-sdvig-kartinki-ssylki.html)

tsigel 11.04.2013 09:43

Цитата:

Сообщение от pagemaster
$("#id1").hover(

$("#1").hover(

pagemaster 11.04.2013 10:03

не работает... пробовал id тега <a> и <div>
<script>
	  $(window).load(function(){
	      
	            $("#1").hover(
	                function (this) {
	                    $(this).stop().animate({
	                    'left': '465px',
	                    'top': '422px'
	                    }, 800);
	                },
	                function () {
	                    $(this).stop().animate({
	                    'left': '465px',
	                    'top': '422px'
	                    }, 800);
	                }
	            );
	      
	        });
	 
	</script>
	
	  </div>


<div id="1"> <a href="#" style="position:absolute; overflow:hidden; left:465px; top:922px; width:180px; height:255px; z-index:0"><img src="images/1.png"></a></div>

tsigel 11.04.2013 10:11

Естественно не работает! И не должно работать. Вы присваиваете position absolute для ссылки, а двигать пытаетесь див.

tsigel 11.04.2013 10:12

Цитата:

Сообщение от pagemaster
$("#1")

$("#1 a")

pagemaster 11.04.2013 10:27

Смотрите, я с дива убрал id и поставил его тегу <a>, не работает.
Потом вернул все обратно и написал $("#1 a"), но тоже не работает!..
Вот весь код:
<script>
	  $(window).load(function(){
	      
	            $("#1 a").hover(
	                function (this) {
	                    $(this).stop().animate({
	                    'left': '465px',
	                    'top': '422px'
	                    }, 800);
	                },
	                function () {
	                    $(this).stop().animate({
	                    'left': '465px',
	                    'top': '422px'
	                    }, 800);
	                }
	            );
	      
	        });
	 
	</script>
	
	  </div>


<div id="1"> <a href="#" style="position:absolute; overflow:hidden; left:465px; top:922px; width:180px; height:255px; z-index:0"><img src="images/1.png"></a></div>

tsigel 11.04.2013 10:30

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<div id='1'>
  <a href='#' style='width: 60px; height: 20px; position: absolute; top: 0; left: 0'>aaa</a>
</div>

<div>
  <a id='2' href='#' style='width: 60px; height: 20px; position: absolute; top: 0; left: 100px'>aaa</a>
</div>

<script>

  $(window).load(function(){
	 
	        $('#1 a').hover(
	            function () {
	                $(this).stop().animate({
					'left': '50px',
					'top': '20px'
					}, 300);
	            },
	            function () {
	                $(this).stop().animate({
					'left': '0px',
					'top': '0px'
					}, 300);
	            }
	        );	   

   $('#2').hover(
	            function () {
	                $(this).stop().animate({
					'left': '50px',
					'top': '20px'
					}, 300);
	            },
	            function () {
	                $(this).stop().animate({
					'left': '100px',
					'top': '0px'
					}, 300);
	            }
	        );
	 
	    });

</script>

pagemaster 11.04.2013 10:35

мне кажется или он не работает?) текст не движется

pagemaster 11.04.2013 10:35

во, заработало) все, спасибо огромное)) буду разбираться

tsigel 11.04.2013 10:36

Что выдает консоль? Вы вообще подключили jQuery?

pagemaster 11.04.2013 11:07

все, работает, jQuery конечно же подключил, ответы на все мои вопросы получил =) спасибо Вам


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