循环赋值,给某个标签加个onclick事件

来源:互联网 发布:淘宝酒店椅套 编辑:程序博客网 时间:2024/05/17 05:16
$(function(){//id*是指包含的意思,所有id包含obj_的都满足条件$("span[id*='obj_']").each(function(index){var templeId=$(this).attr("idValue");$(this).click(function(){guanzhuTemple(templeId);});});});

<%@ page language="java" contentType="text/html; charset=utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><span id="obj_${templeInfo[0]}" idValue="${templeInfo[0]}"  <c:if test="${templeGuanzhuMap[templeInfo[0]]==null || templeGuanzhuMap[templeInfo[0]]==0}"></c:if>  <c:if test="${templeGuanzhuMap[templeInfo[0]]==1}"></c:if>   sc="guanzhu">   <a href="javascript:void(0);">关注</a><em class="ft">(</em><span id="num${templeInfo[0]}" class="ft">${relateMap[templeInfo[0]]}</span><em class="ft">)</em>    </span>|</body></html>

0 0
原创粉丝点击