Obtain all buttons in MVC and bind events !, Mvc binding
<Script> var btns = $ ('[id = addbtn]'); // The # ID cannot be used directly. You must use [] // to traverse all the buttons cyclically, bind events one by one for (var I = 0; I <btns. length; ++ I) {btns [I]. onclick = function () {var name = this. getAttribute ('name'); // this is the attribute value in the current button. Put all the values I want to obtain in the button and pass them to the input box var tel = this. getAttribute ('tel'); var add = this. getAttribute ('add'); // alert ("click the button, uid =" + uid); $ ('# username '). val (name); $ ('# address '). val (add); $ ('# UserTel '). val (tel) ;}}</script>
In MVC...
<A href = "#" id = "addbtn" name = "@ item. Name" tel = "@ tel. Tel" add = "@ if (item. Address! = "" & Item. Address! = Null) {@ item. Address} "class =" btn-default "> dispatch </a> // generate all values to be passed on this button ..