tags:

views:

76

answers:

3

Hi Guys,

I am using HTML and Jquery

Below is the html code for TD which gets appended after matching the IDs from below LI HTML code

<td style="border-top-style: solid; border-right-style: solid; border-left-style: solid;
                    border-bottom-style: solid" id="Physical">
                    Physical Science Course
                </td>

    <li id="PhysicalTooltip"><a href="#" target="_blank" class="toolTip">
        <img src="/images/q_mark.gif" alt="" /><span style="width: 300px; padding: 10px 10px 10px 55px;">Testing
            Physical.</span></a> </li>

Here is Jquery which matches the relative IDs and takes tag from above LI and further append in above TD

$(document).ready(function() 
            {

                    // bind to cells with an ID attribute
                    $("table > tbody > tr > td[id]").each(function() 
                    {                

                        // grab the anchor from the LI whose ID starts with the cell's ID
                        var $tooltip = $("div:hidden li[id^=" + $(this).attr("id") + "] a");

                        //alert($tooltip);

                        // append it to the current cell
                        $(this).append($tooltip);

                    });
            });

Now I want to remove my target attribute from before it gets appended to above TD.

Please suggest!

+1  A: 
$("#PhysicalTooltip a").attr("target", "");
David Morton
+1  A: 

You need to find the anchor inside the list element and use removeAttr.

$tooltip.find('a').removeAttr('target');
tvanfosson
A: 

Hi Guys,

I resolved my problem using below code

   $(document).ready(function() 
    {

            // bind to cells with an ID attribute
            $("table > tbody > tr > td[id]").each(function() 
            {                

                // grab the anchor from the LI whose ID starts with the cell's ID
                var $tooltip = $("div:hidden li[id^=" + $(this).attr("id") + "] a").attr("target", "_self");

                //alert($tooltip);

                // append it to the current cell
                $(this).append($tooltip);

            });
    });
MKS
You can do the same thing with @tvanfosson or @David's answers. You are essentially doing the same thing that they have suggested (although you are setting the target to `_self` whereas they are either removing it completely, or setting it to be empty.
Blair McMillan