使用jQuery从label获取值

我希望从标签中获得月份和年份价值.我如何使用 jquery获取这些?
<label year="2010" month="6" id="current Month"> June &nbsp;2010</label>

解决方法

首先,我不认为id的空格是有效的.

所以我将id更改为不包含空格.

<label year="2010" month="6" id="currentMonth"> June &nbsp;2010</label>

然后jquery代码很简单(请记住,最好一次获取jquery对象并使用遍历agian)

var label = $('#currentMonth');
var month = label.attr('month');
var year = label.attr('year');
var text = label.text();

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...