3 回答
TA贡献2051条经验 获得超10个赞
<button type="button">Button</button>
=)
TA贡献2039条经验 获得超7个赞
<button type="button" onclick="addItem(); return false;">Add Item</button><button type="button" onclick="removeItem(); return false;"> Remove Last Item</button>
removeItem()
function removeItem() { var rows = $('form tr'); if ( rows.length > 2 ) { // change: work on filtered jQuery object rows.filter(":last").html(''); $('form :hidden:last').val(''); } else { alert('Cannot remove any more rows'); }}
$(function() // execute once the DOM has loaded{ // wire up Add Item button click event $("#AddItem").click(function(event) { event.preventDefault(); // cancel default behavior //... rest of add logic }); // wire up Remove Last Item button click event $("RemoveLastItem").click(function(event) { event.preventDefault(); // cancel default behavior //... rest of remove last logic });});...<button type="button" id="AddItem" name="AddItem">Add Item</button><button type="button" id="RemoveLastItem" name="RemoveLastItem">Remove Last Item</button>
type
submit
TA贡献1796条经验 获得超10个赞
<form method="post" id="theFormID" name="theFormID" action=""> <input type="text" id="Field1" name="Field1" /> <input type="text" id="Field2" name="Field2" /> <input type="submit" value="Send" onclick="JavaScript:return Validator();" /></form>
onsubmit="..."
onclick
true
false
.
type="submit"
type="button"
<form method="post" id="theFormID" name="theFormID" action=""> <input type="text" id="Field1" name="Field1" /> <input type="text" id="Field2" name="Field2" /> <input type="button" value="Send" onclick="JavaScript:return Validator();" /></form>
function Validator
return True;
function Validator(){ // ...bla bla bla... the checks if( ){ document.getElementById('theFormID').submit(); return(true); }else{ return(false); }}
id=""
getElementById
name=""
onsubmit
onsubmit
document.getElementById('theFormID').action='./GoToThisPage.php'; // Where to godocument.getElementById('theFormID').submit(); // Send POST data and go there
type="button"
type="submit"
onsubmit
onclick
type="submit"
type="button"
submit()
添加回答
举报