Ok, I have an <a tag that calls a toggle function to remove a <td tag. In that a tag I have <<…<<
In the function I want to change the << to >> when the toggle is performed. Its not working. What am I doing wrong?
html:
<td class="filter_td" id="filter_td">
<td class="show_hide">
<a href="javascript:toggleFilters();" id="show_hide" alt="Hide Filters" title="Hide Filters"><<</a>
</td>
jquery:
function toggleFilters()
{
var td = $("#filter_td");
td.toggle('slow');
if (td.css("display") == "none")
{
$("#show_hide").html(">>").attr('title', 'Show Filters');
}
else
{
$("#show_hide").html("<<").attr('title', 'Hide Filters');
}
}
Put your code that changes the text into the callback for “toggle”. That way, you know the animation is complete and the element’s visible state is complete. Something like this:
Also, I changed the check for it being hidden to jQuery’s “.not()”. This is a more general way of telling if an element is actually visible on the page, instead of simply looking at its styling (which may not be defined).