jQuery: form, function and give attribute
I have a form that on action: action="javascript:DoWallInsert($idf );"..
Now on this form i have this submit button. I want onclick that it should be disabled, and then enabled again on success (the ajax call inside the function).
<input name="submit" type="submit" id="submit" value="Send">
function DoWallInsert(BuID, uID){
$('#submit').attr('disabled', true);
var wrapperId = '#wall_insert';
$.ajax({
type: "P开发者_StackOverflow社区OST",
url: "misc/insertWall.php",
data: {
value: 'y',
BuID : BuID,
uID : uID,
message : $('#message').val()
},
success: function(msg){
$('#submit').attr('disabled', false);
$(wrapperId).prepend(msg);
$(wrapperId).children().first().slideDown('slow');
$('#message').val("");
}
});
}
I tried this, but it doesnt work
You need to remove the disabled
attribute you added earlier (there is no enabled
attribute), so replace this:
$('#submit').attr('enabled', true);
With this:
$('#submit').attr('disabled', false);
To enable a button:
// $('#submit').attr('enabled', true); //incorrect
$('#submit').removeAttr('disabled');
//or $('#submit').attr('disabled', false);
精彩评论