jQuery改变按钮值

时间:2012-04-26 20:59:12

标签: jquery

我正在尝试重置按钮标记的文本。当用户点击按钮时,会进行ajax调用,然后将按钮的标题更改为响应消息(成功或失败)如果他们想要进行更多更改,我需要将其更改回Save。现在它只停留在响应消息上

// SAVE NEW STUDENT DETAILS
  $('#save_student_detail_changes').live('click',function(){
    $('#save_student_detail_changes').text('Save');
    var changes ='&';
    // FIND ALL THE INPUT CHILDREN OF #STUDENT_DETAILS AND INSERT THE VALUE ATTRIBUTE AND THE COL ATTRIBUTE INTO THEIR OWN VARIABLES
     $('#student_details').find("input").each(function() { 
      var value = $(this).attr('value');// VARIABLE FOR VALUE ATTRIBUTE OF INPUT TAG
      var column = $(this).attr('col');// VARIABLE FOR COL ATTRIBUTE OF INPUT TAG
      changes += column + '=' + value + '&' ;// BUILDS THE AJAX QUERY STRING
      var lin = $(this).parent().attr('rel');// GET ID ATTRIBUTE DETAILS
      $(this).parent().attr('id',lin);// MAKE NEW ATTRIBUTE WITH DETAILS FROM ID ATTRIBUTE
      $(this).parent().removeAttr('rel');// REMOVE ID ATTRIBUTE
      $(this).replaceWith(value); // REPLACE INPUT ELEMENT WITH VALUE THAT WAS INSERTED

      });
      $(this) // AJAX CALL
        .html(ajax_load) // SHOW LOADING SPINNING WHEEL
        .load(loadUrl,"form_being_submitted=save_student_detail_changes"+changes);
      $(this).fadeOut(3000);// FADE OUT SAVE BUTTON

1 个答案:

答案 0 :(得分:0)

我最终使用了.ajax()方法。有更多的控制权。

http://api.jquery.com/jQuery.ajax/