关于 jquery 和 freemarker
问题描述:
我分页查出了数据
当我点击"修改"超链接时,第一行没反应
但是其他行是有反应的。
为什么点击第一行就没反应呢?
下面是页面代码:
<#list pageView.list as msg>
onMouseOut="this.style.backgroundColor='white'">
${msg_index+1}
style="cursor:pointer;color:blue;text-decoration: underline">
修改
删除
${msg.title}
${msg.messageContent}
${msg.sendTime?string("yyyy-MM-dd
HH:mm:ss")}
${msg.sender}
</#list>
这是js代码:
$("a[name='editmsg']").click(function(){
$(this).parent().parent().parent().parent().submit();
});
答
你这样生成html是有问题的
<a id="editmsg" name="editmsg" ,生成的所有a都是一直的,这样根本jquery不好唯一定位到哪个a,建议加个遍历变量号,至少id生成的要不同