To get the href you either access the property of the element
directly, or use the attr() function on the jQuery object.
Eg.
(note : I'm using $('a', this) instead of $(this).children()...)
alert( $('a', this)[0].href ); //the [0] retrieves the actual element
or
alert( $('a', this).attr('href') );
On May 30, 12:40 am, eid <[EMAIL PROTECTED]> wrote:
> try getAttribute('href')
>
> On 30 Maj, 00:46, Kierhon <[EMAIL PROTECTED]> wrote:
>
> > Hi all, new to JQ. I'm trying to pass the href from the <a> tag to the
> > ajax load function. I believe i've selected the child properly but for
> > some reason it's not pulling in the href. Any help is greatly
> > appreciated!
>
> > site: new-age-design.com
> > code:
>
> > <?php include('includes/header.php'); ?>
>
> > <div id="header">
> > <div class="container">
> > <h1><a href="index.php">Site In Development</a></h1>
>
> > <ul>
> > <li><a href="#" style="color:#000;">Link</a></li>
> > <li><a href="#">Link</a></li>
> > <li><a href="#">Link</a></li>
> > <li><a href="#">Link</a></li>
> > <li><a href="#">Link</a></li>
> > <li><a href="#">Link</a></li>
> > </ul>
>
> > </div>
> > </div>
>
> > <div class="container">
> > <script type="text/javascript">
> > function passURL(url){
> > var ajaxURL = document.getElementById("test").href;
> > alert (ajaxURL);
> > };
>
> > if(typeof sIFR == "function") {
> > sIFR.replaceElement(
> > named({
> > sSelector: "h1 , dt a span",
> > sFlashSrc:
> > "flash/bleeding_cowboys.swf",
> > sColor: "<?php
> > echo("$h1_color"); ?>",
> > sLinkColor: "<?php
> > echo("$h1_color"); ?>",
> > sHoverColor: "<?php echo("$h1_hover");
> > ?>",
> > sWmode: "transparent",
> > nPaddingTop: 0,
> > nPaddingBottom: 0
> > })
> > );
> > };
>
> > $(document).ready(function(){
> > // $("dd:not(:first)").hide();
> > $("dt").click(function(){
> > // $("dd:visible").slideUp("slow");
> > alert ($(this).children().href);
>
> > $(this).next().load("test.xml").slideDown("slow");
> > return false;
> > });
> > });
> > </script>
>
> > Currently, in Saint Johns, MI the weather is: <?php
> > echo("$weather"); ?>
>
> > <dl>
> > <dt><a id="test" href="test.xml"><span>Div1</span></a></dt>
> > <dd>Test Info</dd>
>
> > <dt><a href="/discuss/">Div2</a></dt>
> > <dd>
> > Test Info<br /><br />
> > </dd>
>
> > <dt><a href="/dev/">Div3</a></dt>
> > <dd>
> > Test Info<br /><br />
> > </dd>
> > </dl>
>
> > </div>
>
> > <div id="footer"></div>
>
> > </body>
> > </html>