The answer I needed - and found in the jQuery documents - was

var parentTag = $('#'+ni).parent().get(0).tagName;

I should have looked more closely sooner.

Cheers,
Bruce



At 04:58 p.m. 30/06/2009, you wrote:
Hello folks,

I have a function, triggered when a particular type of link is clicked, which collects and inserts some text after the parent of the clicked link.

This function works fine when the parent is a p tag, but I'm having trouble when the link is within a list tag. In this instance I would want the new text to be presented after the closing list item tag.

How do can I distinguish whether the clicked link is within a p tag or within an li tag?

Thanks,

Bruce


function fnGetSnippet(ni){
$.get("../scripts/ajax_fsheets.asp?id=getDD&ddID=" + ni + "&q=" + new Date().getTime(), function(responseText){
        $('#'+ni).parent().after(responseText);
        $('#'+ni).unbind('click.drill').addClass('showme');
        var $match = $('#hide'+ni);
        $('#'+ni+'.showme').toggle(function() {
                $match.fadeOut('slow');
                }, function () {
                $match.fadeIn('slow');
                }
        );
});
}

Reply via email to