我有一个可折叠的(输入您的信用卡信息)表格。当我单击它时,它会打开,但是当我单击提交时,我希望它关闭。这是我的html:
<div class= "addStuff">
<div data-role="collapsible" data-inset="true" id="ccdiv">
<h5> New credit card</h5>
<div data-role="fieldcontain">
<form id = "myForm">
<input type="password" name="credit_card_number" id="credit_card_number" value="" placeholder="Credit Card Number">
<input type="password" name="security_code" id="security_code" value="" placeholder="Security Code">
<input type="date" name="expiration_date" id="expiration_date" value="" placeholder="Expiration Date">
<input type="password" name="name" id="name" value="" placeholder="Name On Card">
<input type="password" name="street_address" id="street_address" value="" placeholder="Street Address">
<input type="text" name="city" id="city" value="" placeholder="City">
<input type="number" name="zip_code" id="zip_code" value="" placeholder="Zip Code">
<button type="button" class="submit" name="submit" value="submit">Submit</button>
</form>
</div>
</div>
这是我的 JS 尝试:
$(document).ready(function() {
$('.submit').click(function(){
var creditcard = $('#credit_card_number').val();
$('.accounts #CreditCards div[data-role="content"] #swipeMe').append('<li data-swipeurl="#" ><a href="#">' + creditcard + '</a></li>');
// refresh view
$('#CreditCards ul').listview('refresh');
// hide form
alert('test');
$('#myForm').slideUp();
$('#myForm').trigger('collapse');
});
});