0

トグルでアンカーのテキストを変更しない

HTML:

<a href="#" onclick="javascript:showHide('flight_<?php echo $flightlist->id ?>'); class="fnt-size12">+Flight Details</a>

<div id="flight_<?php echo $flightlist->id; ?>" class="minDetailBox addmarginB10 borT">
   <div class="col1">
      <div class="padding">
         <div class="airLogo"> <span class="airSprites LS2">&nbsp;</span>
            <p>JET Lite</p>
         </div>
      </div>
   </div>
</div>

脚本:

function showHide(id) {       
   var minDetails = document.getElementById(id);        
   $(minDetails).toggle('slow');
  ($(this).text() === "+Flight Details") ? $(this).text("-Flight Details") :  $(this).text("+Flight Details");      
   return false;
}
4

4 に答える 4

0
<a href="#" id="flight1" class="toggle fnt-size12">+Flight Details</a>

jQuery('a.toggle')
    .click(function(e) {
        var id = jQuery(this).attr('id');

        jQuery('#'+id).toggle('slow');
        if(jQuery('#'+id).css('display') == 'none') {
            jQuery(this).html("+Flight Details");
        } else {
            jQuery(this).html("-Flight Details");
        }

        e.preventDefault();
    });
于 2013-10-09T09:49:30.983 に答える