$(this).closest('div').next().slideToggle(function(){
//this code runs when slide toggle is done..
//Here you will have to see if the div is visible or not and apply the appropriate code
});
如果没有您的 HTML,很难确切知道,但类似:
$(document).ready(function(){
$(".component_wrapper").hide();
$(".component_expand").show().click(function () {
$(this).closest('div').next().slideToggle(function(){
if($(this).is(':visible'))
$('.component_expand').html('up arrow');
else
$('.component_expand').html('down arrow');
});
});
});
http://jsfiddle.net/Hwbhm/
更新 2
这个例子更好,值得多个.component_expands
http://jsfiddle.net/Hwbhm/1/