且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用jQuery选择具有特定类的第一个和最后一个元素

更新时间:2023-01-07 11:41:23

var firstspan = $('span.activated:first'),
    lastspan = $('span.activated:last');

顺便说一下,如果您使用的是jQuery,那么所有的内嵌点击事件都会发生什么?

By the way, if you're using jQuery, what's with all the inline click events?

您可以添加如下代码:

You could add some code like so:

$('span.place').click(function() {
    activate(); // you can add `this` as a parameter
                // to activate if you need scope.
});