【发布时间】:2010-02-03 07:29:22
【问题描述】:
在我的页面中,有两个“Conatct Selected”锚按钮,一个在顶部的 id 为“selectAllLink”,另一个在底部的 id 为页面的“selectAllLinkB”。使用以下脚本完美运行的顶部:
<script type="text/javascript">
$(function() {
$('#selectAllLink').each(function() {
var a = [];
var n = $("td.title_listing input:checked");
var s = "";
n.each(function() {
a.push(this.value);
});
s = a.join(',');
if (a.length > 0)
this.href = "/D_ContactSeller.aspx?property=" + s;
else
this.href = 'javascript:alert("Select at least one property to contact!");';
return false;
});
});
现在对于我的底部锚按钮,我尝试将其 id 设置为“selectAllLinkB”并更改如下代码:
<script type="text/javascript">
$(function() {
$('#selectAllLink, selectAllLinkB').each(function() {
var a = [];
var n = $("td.title_listing input:checked");
var s = "";
.....
.....
.....
});
是否有任何简单的方法可以为锚按钮事件调用脚本? 等待快速而良好的响应。提前致谢...
【问题讨论】:
标签: javascript jquery scripting button anchor