我有一个简单的html表单,我已经使用JQuery Validation插件添加了验证.我让它适用于需要值的单个字段.我现在需要来扩展,这样,如果用户回答是一个问题,他们必须输入的详细信息字段的东西,否则详细信息字段可以留空.我正在使用单选按钮显示是/否.这是我完整的html表单 - 我不知道从哪里开始:
<script type="text/javascript" charset="utf-8">
$.metadata.setType("attr", "validate");
$(document).ready(function() {
$("#editRecord").validate();
});
</script>
<style type="text/css">
.block { display: block; }
form.cmxform label.error { display: none; }
</style>
</head>
<body>
<div id="header">
<h1>
Questions</h1>
</div>
<div id="content">
<h1>
Questions Page 1
</h1>
</div>
<div id="content">
<h1>
</h1>
<form class="cmxform" method="post" action="editrecord.php" id="editRecord">
<input type="hidden" name="-action" value="edit">
<h1>
Questions
</h1>
<table width="46%" class="record">
<tr>
<td width="21%" valign="top" class="field_name_left"><p>Question 1</p></td>
<td width="15%" valign="top" class="field_data">
<label for="Yes">
<input type="radio" name="Question1" value="Yes" validate = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将onClick事件添加到锚标记...
以前我有......
<a href="somlink.html" onClick="pageTracker._link(this.href); return false;">
但我试图避免内联onClick事件,因为它干扰了另一个脚本..
所以使用jQuery我正在尝试以下代码...
<script>
$(document).ready(function() {
$('a#tracked').attr('onClick').click(function() {window.onbeforeunload = null;
pageTracker._link(this.href);
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
跟html一样 <a id="tracked" href="something.html">
所以我的问题是这应该是有效的,如果不是最好的解决方案是什么?
如何将li添加到ul的中间.
例如,如果我有这样的列表:
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我想<li>new</li>
在第三个列表后添加addiion li()?
我有一个使用getJSON的跨域长轮询请求,回调看起来像这样:
$.getJSON("http://long-polling.com/some.fcgi?jsoncallback=?"
function(data){
if(data.items[0].rval == 1) {
// update data in page
}
});
Run Code Online (Sandbox Code Playgroud)
问题是对长轮询服务的请求可能需要一段时间才能返回,同时可能会发出另一个getJSON请求并更新页面,即使它是陈旧的响应.
Req1:h**p://long-polling.com/some.fcgi上午10:00
Req2:h**p://long-polling.com/some.fcgi?上午10:01
Req1返回并更新页面上午10:02的数据
如果已经有Req2,我想要一种方法来使Req1的返回无效.
谢谢!
我试图在之前的TD中通过jquery检查/取消选择一个选择框.我已经尝试了几个小时的几个组合与prev(),parent(),nearest(),但仍然没有结果...这是示例代码:
<table>
<tr>
<td><input type="checkbox" class="resultcheck"></td>
<td><label class="resultchecklabel">Text 1</label></td>
</tr>
<tr>
<td><input type="checkbox" class="resultcheck"></td>
<td><label class="resultchecklabel">Text 2</label></td>
</tr>
</table>
<script>
$('.resultchecklabel').live('click', function() {
if ($(this).prev('td input:checked').val() != null)
{
$(this).prev('td').prev("input").removeAttr("checked");
}
else
{
$(this).prev('td').prev("input").attr("checked","checked");
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题?非常感谢!
jquery ×5
javascript ×2
conditional ×1
css ×1
html-lists ×1
jsonp ×1
traversal ×1
validation ×1