Below i have posted the code for my Question.On clicking the anchor link, it does toggle. but the class"mytbody3"should hide on anchor link sliding down. i understand, an if condition should solve this but with limited jQuery coding knowledge, i am not sure how to write it. can someone help with this.
Thanks Paul.
I have one more task similar to this.
can you demonstrate this with slideUp and slidDown functionality and animate the sliding for few seconds.
That is of great help as these are the functionalities that I am handling now.
I need the animate effect, as it slides up , the tbody3 should gradually show …come up and vice versa.
I am working on it. Meanwhile, if I get code , that’s of great help.
slideToggle() is not achieving it. dont’ know why.
giving,
$(‘.mytbody1’).toggle(); //this is what works. giving $(‘.mytbody1’).slideToggle(); makes the mytbody3 to appear first and then toggles up. so changed slideToggle to toggle.
$(‘.mytbody3’).toggle();
actually the above two lines toggles perfect but i need gradual sliding. i also tried with slideUp, it slidesUp but not gradually. i messing/missing something.
once again i put my question here:
.mytbody1 slides up gradually and hides while .mytbody3 comes out gradually and shows and vice versa on clicking the anchor link. the link also goes up and down as per the sliding.
i am making some mistakes in jQuery and not able to identfify the correct syntax. will try to give an working external link.
Any help is highly appreciated. got to finish this. any working example would be great.
Tables cause problems when it comes to animating things like that. See for example some test code at http://jsfiddle.net/pmw57/yZP7s/
The table row only animates to the minimum height of the row. Beyond that, the row just hides itself.
You may have much greater success with the sliding animation by not using tables for layout - which is a big no-no, and instead use divs and some CSS to achieve the layout.
hey paul, i am stuck here and i need to fix this. it’s going to be table. so there is not going to be any other layout. cannot call jquery inside html(not in content). will calling .td or .tr. or using .parent().child()…some syntax using this will work? if so, how i should write it. i have been seeing lot of these syntax while search.
A good way to do that is to wait until the slideToggle has finished, and then check if what you are sliding is visible.
You can the set the text to what you want it to be, based on whether things are visible or not. For example:
// Why slideToggle is not good for table rows
$(function () {
$('#clickme').on('click', function () {
var button = this;
$('#row1').slideToggle(500, function () {
var isVisible = $(this).is(':visible'),
text = isVisible ? 'Slide up' : 'Slide down';
$(button).html(text);
});
});
});