假设我有一些class =“A”的元素;如何确定哪个元素鼠标结束,离开或单击,如何获取其选择器如“.A:eq(n)”?
SELECT location.Id, (SELECT COUNT(property.Id) FROM Property AS property WHERE property.Location.Filter(Geography::Parse('POLYGON ((' + location.GeoPolygon + '))')) = 1) AS PropertyCount
FROM Location AS location
答案 0 :(得分:0)
您可以使用getPath jQuery插件。
jQuery.fn.extend({
getPath: function( path ) {
// The first time this function is called, path won't be defined.
if ( typeof path == 'undefined' ) path = '';
// If this element is <html> we've reached the end of the path.
if ( this.is('html') )
return 'html' + path;
// Add the element name.
var cur = this.get(0).nodeName.toLowerCase();
// Determine the IDs and path.
var id = this.attr('id'),
class = this.attr('class');
// Add the #id if there is one.
if ( typeof id != 'undefined' )
cur += '#' + id;
// Add any classes.
if ( typeof class != 'undefined' )
cur += '.' + class.split(/[\s\n]+/).join('.');
// Recurse up the DOM.
return this.parent().getPath( ' > ' + cur + path );
}
});
答案 1 :(得分:0)
你不需要自己迭代它们,jquery会为你做这件事。如果您需要元素的索引,只需使用index()
。现在我不太清楚你想要实现什么,但你可以尝试类似的东西,
$('.A').click(function() {
var outer_index = $(this).index();
$('.A').each(function(inner_index) {
generateTableAns(outer_index, $(this), outer_index*inner_index);
});
});
基本上$(this)
是您要迭代的元素。使用this
。