Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
$(document).ready(function () {

    $("input[name='Round_trip']").on('click', function () {
        console.log("changed");
        if ($("input[name='Round_trip']:checked").val() === 'false')
            $("#returnFlightInfo").fadeOut();//this didn't work
        else
            $("#returnFlightInfo").fadeIn();//this didn't work

        console.log($("input[name='Round_trip']:checked").val());
//the console.log indeed show change and the value is correct
    });

})
Posted

put these lines in if and else part.

console.log("if part True");
console.log("else part True");

by using following line check, are you able to access #returnFlightInfo

console.log($(#returnFlightInfo).innerHTML());
 
Share this answer
 
Comments
SandyZhang2014 9-Feb-15 23:38pm    
console.log($(#returnFlightInfo).innerHTML()); show error, say .innerHTML() is not function
SandyZhang2014 9-Feb-15 23:41pm    
changed
SydneyValidation.js:104 false
SydneyValidation.js:106
<div class="col-lg-4">
<div class="form-group has-feedback">
<label class="control-label">Return flight #</label>
<input class="form-control" id="Return_Flight_Number" name="Return_Flight_Number" placeholder="Flight Number" type="text" value="" data-bv-field="Return_Flight_Number">
Please enter your return flight number</div>
</div>

<div class="col-lg-4">
<div class="form-group has-feedback">
<label class="control-label">Date</label>
<input class="form-control" data-val="true" data-val-date="The field Return_Flight_Date must be a date." id="datetimepickertimereturnDate" name="Return_Flight_Date" placeholder="Flight Date" type="text" value="" data-bv-field="Return_Flight_Date">

Please select your return flight date</div>
</div>

<div class="col-lg-4">
<div class="form-group has-feedback">
<label class="control-label">Time</label>
<input class="form-control" id="datetimepickertimereturnTime" name="Return_Flight_Time" placeholder="Flight Time" type="text" value="" data-bv-field="Return_Flight_Time">

Please select your return flight time</div>
</div>

The console show correct, but still won't hide
SandyZhang2014 9-Feb-15 23:44pm    
I just don't get it, it is very simple jQuery function fadeOut and fadeIn,and console show info is correct,but fadeOut and fadeIn won't work
Check this out:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function () {
 
    $("input[name='Round_trip']").on('click', function () {
        
        if ($("input[name='Round_trip']:checked").val() === 'hide')
            $("#returnFlightInfo").fadeOut();
        else
            $("#returnFlightInfo").fadeIn();

        echo($("input[name='Round_trip']:checked").val());
    });
})
</script>
</head>
<body>
<input type="radio" name="Round_trip" value="show" checked>Show
<input type="radio" name="Round_trip" value="hide">Hide
<br>
<p id="returnFlightInfo">Return Flight Info...</p>

</body>
</html>
 
Share this answer
 
Comments
SandyZhang2014 9-Feb-15 23:37pm    
the answer should work,but It just don't work,
I could access #returnFlightInfo, I just hide when people choose single trip,I use button it work, but now I choose radio button then don't work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900