C# 我想点击的时候获取下列代码中的title属性,我写了一个js怎么不行呢!而且这个js好像没有加载
<scripttype="text/javascript">$('document').ready(function(){$("dldtdd:a").click(func...
<script type ="text/javascript" >
$('document').ready(function()
{
$("dl dt dd :a").click(
function()
{
alert($(this).attr('id'));
alert($(this).html());
alert($(this).attr('title'));
// document .getElementById ("title").innerHTML="点击成功";
}
);
});
</script>
<body>
<form id="form1" runat="server">
<div>
<dl id="gmap">
<dt><a id="title2" ></a></dt>
<dd><a id="xj" title="新疆" href="javascript:void(0)" runat="server">新疆</a></dd>
<dd><a id="xz" title="西藏" href="javascript:void(0)" runat="server">西藏</a></dd>
<dd><a id="qh" title="青海" href="javascript:void(0)" runat="server">青海</a></dd>
<dd><a id="gs" title="甘肃" href="javascript:void(0)" runat="server">甘肃</a></dd>
<dd><a id="lmg" title="内蒙古" href="javascript:void(0)" runat="server">内蒙古</a></dd>
<dd><a id="hlj" title="黑龙江" href="javascript:void(0)" runat="server">黑龙江</a></dd>
<dd><a id="jl" title="吉林" href="javascript:void(0)" runat="server">吉林</a></dd>
<dd><a id="ln" title="辽宁" href="javascript:void(0)" runat="server">辽宁</a></dd>
<dd><a id="sd" title="山东" href="javascript:void(0)" runat="server">山东</a></dd>
<dd><a id="hb" title="河北" href="javascript:void(0)" runat="server">河北</a></dd>
</dl>
</div>
<asp:Label id="lbl1" runat="server" Text="Label1"></asp:Label>
<asp:Label ID ="title" runat ="server" Text ="label2"></asp:Label>
</form>
</body>
</html> 展开
$('document').ready(function()
{
$("dl dt dd :a").click(
function()
{
alert($(this).attr('id'));
alert($(this).html());
alert($(this).attr('title'));
// document .getElementById ("title").innerHTML="点击成功";
}
);
});
</script>
<body>
<form id="form1" runat="server">
<div>
<dl id="gmap">
<dt><a id="title2" ></a></dt>
<dd><a id="xj" title="新疆" href="javascript:void(0)" runat="server">新疆</a></dd>
<dd><a id="xz" title="西藏" href="javascript:void(0)" runat="server">西藏</a></dd>
<dd><a id="qh" title="青海" href="javascript:void(0)" runat="server">青海</a></dd>
<dd><a id="gs" title="甘肃" href="javascript:void(0)" runat="server">甘肃</a></dd>
<dd><a id="lmg" title="内蒙古" href="javascript:void(0)" runat="server">内蒙古</a></dd>
<dd><a id="hlj" title="黑龙江" href="javascript:void(0)" runat="server">黑龙江</a></dd>
<dd><a id="jl" title="吉林" href="javascript:void(0)" runat="server">吉林</a></dd>
<dd><a id="ln" title="辽宁" href="javascript:void(0)" runat="server">辽宁</a></dd>
<dd><a id="sd" title="山东" href="javascript:void(0)" runat="server">山东</a></dd>
<dd><a id="hb" title="河北" href="javascript:void(0)" runat="server">河北</a></dd>
</dl>
</div>
<asp:Label id="lbl1" runat="server" Text="Label1"></asp:Label>
<asp:Label ID ="title" runat ="server" Text ="label2"></asp:Label>
</form>
</body>
</html> 展开
2个回答
展开全部
你得末尾结束分号是中文的 换成英文;
追问
在js中加了var city = $(this).attr('title');document.getElementById("title").innerHTML =city;document.getElementById("btncity").click();btncity是一个button,后台click事件引用label的text,但是运行的时候,发现label的text没有改变。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询