Div标记内容未在点击中显示

时间:2016-09-13 07:40:34

标签: javascript jquery html

我试图在href点击上显示div标签的数据,id是动态制作的。但div标签没有响应。代码的顺序如下。该文件是.tpl文件。



<a href style="float:right;margin-top:-20px;margin-right:100px;" onclick="editPickUpAddress({$item.profile_id});">Edit</a>

 <div id="pickupAddressForm_{$item.profile_id}" style="display:none">
   //some content to display
   </div>
&#13;
IF datalength(U_Partner) > 5 THEN save value '9999' into room_id and U_Partner value into partners_id  
IF datalength(U_Partner) <= 4 THEN save value U_Partner into room_id and '9999'
value into partners_id

CASE WHEN datalength T5.U_Partner > 5 THEN '9999' ELSE T5.U_Partner END as room_id,
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

清理完代码片段并包含jQuery后,代码按预期工作。另请注意href="#",它会阻止锚标记导航到另一个页面。

function editPickUpAddress(divId) {
  $("#pickupAddressForm_" + divId).show();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" onclick="editPickUpAddress(1);">Edit</a>

<div id="pickupAddressForm_1" style="display:none">
  //some content to display
</div>