2

我遇到了一个非常奇怪的问题。如果您单击类:“change_btn”,我想显示一个特定的 div。但唯一有效的是密码形式(passwordFC)。当我单击其他按钮时,什么都看不到。他们有内容。怎么会这样?

我已经尝试了几个小时,感谢您的帮助。

最好的问候吉米

jQuery

jQuery(function($) {

    /* Make the password form show first as standard */
    $(".settingsFC").hide();
    $(".passwordFC").show();

    /* Function that shows the right form when clicking the buttons */

    $(".change_btn").click(function() { 

        $choosenForm = "." + $(this).attr("title"); 

        /* Remove the style on the other buttons */
        $(".settingButton").css('background-color','#ebeaea');
        $(".settingButton").css('font-weight','normal');

        /* Add style to clicked button */
        $(this).css('background-color','#e0e0e0');
        $(this).css('font-weight','bold');

        /* Hide the other containers, if i remove this they show when clicking. */
        $(".settingsFC").hide();

        /* Tried this one as well, didnt work */
        //$(".settingsFC:not(."+$choosenForm+")").hide();

        /* Show the right container */
        $($choosenForm).show();

    });
});

html

<div title="passwordFC"  class="settingButton px10 change_btn firstSettingsChoice"> INLOGGNING </div>
<div title="personalFC" class="settingButton px10 change_btn"> PERSONLIGT </div>
<div title="paymentFC"  class="settingButton px10 change_btn"> BETALNINGSPLAN </div>
<div title="cloudFC"  class="settingButton px10 change_btn"> CLOUD INSTÄLLNINGAR </div>


<div class="settingsFC passwordFC">
    <?php include("includes/changeSettings/changePassword.php"); ?>
</div> <!-- changePassword -->

<div class="settingsFC personalFC">
    <?php include("includes/changeSettings/changePersonal.php"); ?>
</div> <!-- changePersonal -->

<div class="settingsFC paymentFC">
    <?php include("includes/changeSettings/changePayment.php"); ?>
</div> <!-- changePayment -->

<div class="settingsFC cloudFC">
    <?php include("includes/changeSettings/changeCloud.php"); ?>
</div> <!-- changeCloud -->
4

1 回答 1

-1

这是你需要做的。工作小提琴(删除 PHP 东西进行测试) -小提琴

$(document).ready(function() {

  /* Make the password form show first as standard */
  $(".settingsFC").hide();
  //$(".passwordFC").show();


  /* Function that shows the right form when clicking the buttons */

  $(".change_btn").click(function() { 

         var choosenForm = "." + $(this).attr("title"); 

         /* Remove the style on the other buttons */
         $(".settingButton").css('background-color','#ebeaea');
         $(".settingButton").css('font-weight','normal');

         /* Add style to clicked button */
         $(this).css('background-color','#e0e0e0');
         $(this).css('font-weight','bold');

         /* Hide the other containers, if i remove this they show when clicking. */
          $(".settingsFC").hide();

         /* Tried this one as well, didnt work */
         //$(".settingsFC:not(."+$choosenForm+")").hide();

         /* Show the right container */
         $(choosenForm).show();

    });
});​
于 2012-11-15T18:49:32.337 回答