那么有人可以告诉我们为什么这些选项都不会真正提交表格?我正在尝试做一些更复杂的事情,但我已经将其归结为此尝试找出为什么我似乎无法使用click事件提交此表单并提交()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('#submitButton').click(function(e) {
e.preventDefault();
$("#testForm").submit();
});
$('#submitLink').click(function(e) {
e.preventDefault();
$("#testForm").submit();
});
});
</script>
</head>
<body>
<form action="javascript:alert('submitted');" method="post" id="testForm">
<label>Name</label>
<input type="text" name="name" value="" />
<input type="submit" name="submit" value="Submit" id="submitButton" />
<p><a href="#" id="submitLink">Submit Form</a></p>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在尝试做一些我认为应该相当简单的事情,但我的结果不稳定.我想打开一个对话框,其中有2个地址字段,使用谷歌地图自动完成功能根据用户输入的内容建议位置.我能够显示"输入位置"字段,告诉我谷歌地图api呼叫正在运行,但它不是自动完成地址.
编辑:好的我确定了问题.位置下拉列表最终位于对话框后面,因此不可见.那么有人可以告诉我如何更改query-ui对话框和叠加层或谷歌地图下拉框的z-index?
以下是我创建的示例的链接,因为您需要注册以供网站使用. http://google.backcountryride.com/dialog_google_test.php
这是我的代码:JQuery:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places,geometry&sensor=false"></script>
<script type="text/javascript">
$(function() {
var post = $( "#post<?php echo $instance ?>" ),
role = $( "#role<?php echo $instance ?>" ),
allFields = $( [] ).add( post ).add( role),
tips = $( ".validateTips" );
function updateTips( t ) {
tips
.text( t )
.addClass( "ui-state-highlight" );
setTimeout(function() {
tips.removeClass( "ui-state-highlight", 1500 );
}, 500 );
}
function checkLength( o, n ) {
if ( o.val().length < 1 ) {
o.addClass( "ui-state-error" ); …Run Code Online (Sandbox Code Playgroud)