Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将迭代器的id从发送到javascript函数_Javascript_Struts2 - Fatal编程技术网

如何将迭代器的id从发送到javascript函数

如何将迭代器的id从发送到javascript函数,javascript,struts2,Javascript,Struts2,我想通过链接沙化迭代器的id 我试过了,但没用 我的链接是这样的 <s:iterator value="answerList" status="id"> <a class="link" href="javascript:countactu_Form('+"%{#id.index}"+')" >add Comment</a> <div id="Contactu-Form-%{#id.index}" > <s:textarea

我想通过链接沙化迭代器的id 我试过了,但没用

我的链接是这样的

 <s:iterator  value="answerList" status="id">

 <a  class="link" href="javascript:countactu_Form('+"%{#id.index}"+')" >add Comment</a>
 <div id="Contactu-Form-%{#id.index}" >
   <s:textarea name="description" rows="5" cols="60" theme="simple" />
  </div>
 function countactu_Form(id){
            alert("123456789");
            alert(id);
            $('#Contactu-Form-'+id).animate({
                height: 'toggle'
            },150, function() {
                // Animation complete.
            });
        }

请下次发布链接的查看源

应用@Umesh的建议并更改脚本以在更多浏览器中工作,请尝试

并将函数更改为返回false

function countactu_Form(id){
  $('#Contactu-Form-'+id).animate({
    height: 'toggle'
  },150, function() {
  // Animation complete.
  });
  return false;
}

@mplungjan它仍然无法获取id。它只是将字符串%{id.index}作为id@mplungjan:您已经编辑了您的答案,我相信对于面临相同问题的人来说,这已经足够了:好的,这只是您实际解决方案的代表尝试这个,它应该会起作用@Umeshawashi谢谢,它很好…@Umeshawashi请发布为答案