jQuery toggle disabled click on link
how do I enable a toggle function on a table row, while still maintaining the ability to click through to the page specified in a link? T开发者_开发技巧he link is within the td, like table tr td a
.
The HTML for the row looks like this:
<tr class="listitem">
<td>
<a href="/apartments/4df632fd35be357701000005">E 64th St, Manhattan, NY 10065, USA</a>
</td>
...
</tr>
And so far the JavaScript I am using is something like this:
$('.listitem').toggle(function(){...}, function(){...});
Which is disabling the ability to click on the <a>
element. How do I get around this?
toggle()
function does not disable the ability to click, as I know. Or, show me the example with http://jsfiddle.net/, please.
And you are using toggle()
function in a wrong way. You can't pass two function arguments to toggle()
function. Check this documentation: http://api.jquery.com/toggle/
what about event.preventDefault();
If i understand correctly what you want, you should be able to register a different callback for the anchors, much the same way you defined them for the tablerows.
I'm not certain what you're doing in the toggle functions that's preventing the link from working, but one thing you could try is to prevent event propagation to the tr when the link is clicked on:
$('tr a').click(function(e){
e.stopPropagation();
});
You given two parameters two toggle()
, which both are function()
s, but as much i know toggle()
takes duration
as 1st parameter and callback
as second parameter. Please check this.
精彩评论