Getting value from href using jQuery

Posted by bateman_ap on Stack Overflow See other posts from Stack Overflow or by bateman_ap
Published on 2010-04-28T14:44:46Z Indexed on 2010/04/28 14:53 UTC
Read the original article Hit count: 453

Hi, I wonder if anyone can help with a jQuery problem I am having.

I am using the tooltips from the Jquery Tools library to create a popup window when mousing over an hrefed image, this I want to use to cusomise the call to change the content in the DIV.

The links I am using are in the form:

<a href="/venue/1313.htm" class="quickView"><img src="/images/site/quickView83.png" alt="Quick View" width="83" height="20" /></a>

The code I am using to trigger the tip is:

$(".quickView").live('mouseover', function()
    {
        if (!$(this).data('init'))
        {
            $(this).data('init', true);
            ajax_quickView(); 
            $(this).tooltip
            ({ 
                /* tooltip configuration goes here */ 
                tip: "#quickViewWindow",
                position: "right",
                offset: [0, -300], 
                effect: 'slide' 
            });
            $(this).trigger('mouseover'); 
        }  
    });

I have tried the following function to grab the ID (in the example above, 1313) from the link:

function ajax_quickView(){
        var pageNum = $("a.quickView").attr("href").match(/venue/([0-9]+)/).htm[1];
        $("#quickViewWindow").load("/quick-view/", function(){}) 
    }

However I think this is where it falls down, I think my regex is prob to blame...

Once I get the var pageNum I presume I can just pass it into the .load as:

$("#quickViewWindow").load("/quick-view/", {id : pageNum }, function(){})

Many thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors