如果你有这样的表格
<form name='aform' id='myform' action='somescript.php' method='POST'>
<input type='text' id='txtinput' value='' />
<input type='button' id='mybutton' name='mybutton' value='My text'/>
<input type='submit' id='mysubmit' value='submit'/>
</form>
你可以这样做
<script type="text/javascript">
$(document).ready(function()
{
$('#mybutton').click(function(){
$('#txtinput').attr('value',$(this).attr('value'));
});
$('#mysubmit').click(function(v){
var mixinput = $('#txtinput').attr('value');
var cleaninput =mixinput.replace($('#mybutton').attr('value'),'');
alert(cleaninput);
v.preventDefault();
v.stopPropagation();
});
}
</script>
现在它不只是用值来提醒你 remove v.preventDefault(); v.stopPropagation(); 并提醒正常发布值...
发布价值观