在jquery中无法在点击事件中显示特定div

时间:2017-06-13 11:00:05

标签: javascript jquery asp.net-mvc

我在asp.net mvc应用程序中工作,在jquery中编写了以下代码

 $(document).ready(function () {

    $(".field-validation-error").hide();
    $(".select-billing-address-button").click(function () {

        $(".edit-address").hide();

        $("#billing-address-select").val(this.value);

        $(".new-address-next-step-button").click();

       $('html,body').animate({

           scrollTop: $(".new-billing-address").offset().top

       }, 'slow');

    });

    $(".adress-new-submit").click(function () {

        $(".field-validation-error").show();

        $(".new-address-next-step-button").click();

        $('html,body').animate({

            scrollTop: $(".new-billing-address").offset().top

        }, 'slow');

    });

$( “字段验证错误”)隐藏();此代码为字段验证字段

但是当我点击adress-new-submit

时,我想取消隐藏字段验证字段

按钮。使用代码$(“。field-validation-error”)。show();但我无法

使用上面的代码实现目标。任何人帮助我

我的html视图如下

<div class="edit-address">
<div class="inputs">
    <label for="BillingNewAddress_FirstName">First name:</label>
        <input class="text-box single-line" data-val="true" data-val-required="First name is required." id="BillingNewAddress_FirstName" name="BillingNewAddress.FirstName" type="text" value="John">
    <span class="required">*</span>
    <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.FirstName" data-valmsg-replace="true"></span>
</div>
<div class="inputs">
    <label for="BillingNewAddress_LastName">Last name:</label>
        <input class="text-box single-line" data-val="true" data-val-required="Last name is required." id="BillingNewAddress_LastName" name="BillingNewAddress.LastName" type="text" value="Smith">
    <span class="required">*</span>
    <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.LastName" data-valmsg-replace="true"></span>

</div>
<div class="inputs">
    <label for="BillingNewAddress_Email">Email:</label>
        <input class="text-box single-line" data-val="true" data-val-email="Wrong email" data-val-required="Email is required." id="BillingNewAddress_Email" name="BillingNewAddress.Email" type="text" value="rakshiraik@gmail.com">
    <span class="required">*</span>
    <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.Email" data-valmsg-replace="true"></span>
</div>
    <div class="inputs">
        <label for="BillingNewAddress_Company">Company:</label>
            <input class="text-box single-line" id="BillingNewAddress_Company" name="BillingNewAddress.Company" type="text" value="">
        <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.Company" data-valmsg-replace="true"></span>
    </div>
        <div class="inputs">
        <label for="BillingNewAddress_CountryId">Country:</label>

        <span class="required">*</span>
        <span class="field-validation-error" data-valmsg-for="BillingNewAddress.CountryId" data-valmsg-replace="true" style="display: none;">Country is required.</span>
    </div>

    <div class="inputs">
        <label for="BillingNewAddress_StateProvinceId">State / province:</label>                
        <span id="states-loading-progress" style="display: none;" class="please-wait"></span>
        <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.StateProvinceId" data-valmsg-replace="true"></span>
    </div>


<input id="Location" name="Location" type="text" value="" placeholder="Enter a location" autocomplete="off" style="width:400px;"><br><br>

    <div class="inputs">
        <label for="BillingNewAddress_City">City:</label>

    </div>
        <div class="inputs">
        <label for="BillingNewAddress_Address1">Address 1:</label>

   <span class="required">*</span>      
    </div>
        <div class="inputs">
        <label for="BillingNewAddress_Address2">Address 2:</label>
            <input class="text-box single-line" id="BillingNewAddress_Address2" name="BillingNewAddress.Address2" type="text" value="">
        <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.Address2" data-valmsg-replace="true"></span>
    </div>
        <div class="inputs">

    </div>
        <div class="inputs">
        <label for="BillingNewAddress_PhoneNumber">Phone number:</label>

    </div>
        <div class="inputs">

            <input class="text-box single-line" id="BillingNewAddress_FaxNumber" name="BillingNewAddress.FaxNumber" type="text" value="">
        <span class="field-validation-valid" data-valmsg-for="BillingNewAddress.FaxNumber" data-valmsg-replace="true"></span>
    </div>

<button type="button" title="Continue" class="button-1 adress-new-submit">Continue</button>

1 个答案:

答案 0 :(得分:0)

您可以尝试使用.toggle()代替.show()

CREATE TRIGGER builder_update_trigger_manual
AFTER UPDATE
ON edmonton.permit_table
FOR EACH ROW
WHEN (old.builder IS DISTINCT FROM new.builder)
EXECUTE PROCEDURE edmonton.automated_builder_update_trigger_manual();

有时使用ID工作,代替$(“。field-validation-error”)。toggle();给它一个id之后使用“#idName”。 确保你尝试了一切。