Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Помогите прикрепить скрипт к меню (https://javascript.ru/forum/misc/37572-pomogite-prikrepit-skript-k-menyu.html)

DR.GONZO 25.04.2013 06:08

Помогите прикрепить скрипт к меню
 
Вот этот скрипт.

<script language="javascript">
		$(document).ready(function() {

			/* 	1st example	*/

			/// wrap inner content of each anchor with first layer and append background layer
			$("#menu li a").wrapInner( '<span class="out"></span>' ).append( '<span class="bg"></span>' );

			// loop each anchor and add copy of text content
			$("#menu li a").each(function() {
				$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
			});

			$("#menu li a").hover(function() {
				// this function is fired when the mouse is moved over
				$(".out",	this).stop().animate({'top':	'45px'},	250); // move down - hide
				$(".over",	this).stop().animate({'top':	'0px'},		250); // move down - show
				$(".bg",	this).stop().animate({'top':	'0px'},		120); // move down - show

			}, function() {
				// this function is fired when the mouse is moved off
				$(".out",	this).stop().animate({'top':	'0px'},		250); // move up - show
				$(".over",	this).stop().animate({'top':	'-45px'},	250); // move up - hide
				$(".bg",	this).stop().animate({'top':	'-45px'},	120); // move up - hide
			});
					

			/*	2nd example	*/
			
			$("#menu2 li a").wrapInner( '<span class="out"></span>' );
			
			$("#menu2 li a").each(function() {
				$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
			});

			$("#menu2 li a").hover(function() {
				$(".out",	this).stop().animate({'top':	'45px'},	200); // move down - hide
				$(".over",	this).stop().animate({'top':	'0px'},		200); // move down - show

			}, function() {
				$(".out",	this).stop().animate({'top':	'0px'},		200); // move up - show
				$(".over",	this).stop().animate({'top':	'-45px'},	200); // move up - hide
			});

		});

	</script>


Хочется прикрутить к этому меню

<div class="links"><a href="<?php echo $home; ?>"><?php echo $text_home; ?></a><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a><a href="<?php echo $shopping_cart; ?>"><?php echo $text_shopping_cart; ?></a><a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a></div>
</div>


Демо выглядит так

<div id="menu" class="menu">
			<ul>
				<li><a href="javascript:;">Главная</a></li>
				<li><a href="javascript:;">Портфолио</a></li>
				<li><a href="javascript:;">Услуги</a></li>
				<li><a href="javascript:;">Поддержка</a></li>
				<li><a href="javascript:;">Контакты</a></li>
			</ul>
		</div>

DR.GONZO 25.04.2013 13:08

А главный вопрос.
Как привязать грамотно.

<a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a>

ruslan_mart 25.04.2013 15:26

DR.GONZO, не хочу вникать в эту тему, но просто хочу сказать, что грамотней использовать не <? echo $var ?>, а <?=$var?>.

skrudjmakdak 25.04.2013 16:02

а нельзя было в место php прислать готовую html страничку??


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