Here is the code I'm using right now.
$(window).load(function () {
$('.answer').hide();
});
$('.question').click(function () {
var currentId = $(this).attr('id');
$("#a"+currentId.substr(1)).fadeToggle("fast", func开发者_运维百科tion () {
});
});+
$('#show_hide').click(function () {
$(".answer").fadeToggle("fast", function () {
});
});
The problem is that this code will be triggered if the user clicks anywhere on the same line as the link, and not just on the link itself. Help?
$(".question a")
You can use the selector part of Jquery quite creatively. Searches all elements with class question and then selects all the a tags inside of it
If you want id, then switch to hash
$("#question a")
精彩评论