How to get the button value results submitted from a form submission event

 

 

<! DOCTYPE HTML > 
< HTML > 
< head > 
  < title > How to Obtain the button results submitted from a form submission event? </ Title > 
  < Meta charset = "UTF-. 8" > 
  
  < Script the src = "https://code.jquery.com/jquery-3.1.1.min.js" > </ Script >   
</ head > 
< body > 

< form class = "layui-form" Method = "POST"  > 

< Button type = "value = "0" Lay-Submit = "" Lay-filter = "the demo1" > save </ Button > 
< Button type = "Submit" class = "layui-BTN yllanse"   value = "-. 1"   Lay-Submit = " " Lay-filter =" demo1 " > preview </ the button > 


</ form > 

< Script of the type =" text / JavaScript " > 
// for each button by attribute $ (" form button [type = submit] ") my Yes button, if you are <input type = "submit"> Please $ ( "form input [type = submit]") input into the 

$ ( "form button[type=submit]").click(function() { 
  $("button[type=submit]", $(this).parents("form")).removeAttr("clicked");
  $(this).attr("clicked", "true");
});


$(document).ready(function(){ 

  $('.layui-form').submit(function (event) {

    //$ ( "button [type = submit ] [clicked = true]") This is my form of a button, if you are <input type = "submit" / > Please replace $ ( "input [type = submit ] [clicked = true ] ") val () form. 
    
    var Val = $ ( " Button [type = Submit] [clicked to true =] " ) .val (); 
    the console.log (Val); 
    return  to false ; 
  }); 
  

}); 

</ Script > 

</ body > 
</ HTML >

 

Guess you like

Origin www.cnblogs.com/Abner3721/p/11836712.html