I have the following div
我有以下div
<div class="timeline-axis-grid timeline-axis-grid-minor" style="position: absolute; width: 0px; top: 20px; height: 369px; left: 53.3095px;"></div>
and I want to get this div by its 'left: 53.3095px' value and assign to a variable in Jquery
我想通过它的'left:53.3095px'值得到这个div并分配给Jquery中的变量
5 个解决方案
#1
5
try this:
尝试这个:
$('div.timeline-axis-grid').filter(function() {
return $(this).css('left') == '53.3095px';
})
#2
2
You can use .filter()
你可以使用.filter()
Reduce the set of matched elements to those that match the selector or pass the function's test.
将匹配元素集减少到与选择器匹配的元素或传递函数的测试。
$( "div" )
.filter(function( index ) {
return $(this).css('left') === "53.3095px";
})
#3
2
No that is not available to point any selector that way but instead you can use if conditions to check if a particular element has the exact value then do the intended work:
不可以指向任何选择器,但是你可以使用if条件来检查特定元素是否具有确切的值然后执行预期的工作:
if($('.timeline-axis-grid').css('left') === "53.3095px"){
// do stuff here
}
#4
2
The only way is to filter your collection by testing properties that satisfy your need ...
唯一的方法是通过测试满足您需求的属性来过滤您的收藏...
$('div.timeline-axis-grid-minor').filter(
function(){
var $t = $(this);
return ($t.css('position') == 'absolute'
// && $t.css(... // Add conditions to satify your needs
);
}
);
#5
1
if($('div.timeline-axis-grid').css('left') === "53.3095px"){
////your code
}
Or
要么
if($('div.timeline-axis-grid').style.left === "53.3095px"){
////your code
}
#1
5
try this:
尝试这个:
$('div.timeline-axis-grid').filter(function() {
return $(this).css('left') == '53.3095px';
})
#2
2
You can use .filter()
你可以使用.filter()
Reduce the set of matched elements to those that match the selector or pass the function's test.
将匹配元素集减少到与选择器匹配的元素或传递函数的测试。
$( "div" )
.filter(function( index ) {
return $(this).css('left') === "53.3095px";
})
#3
2
No that is not available to point any selector that way but instead you can use if conditions to check if a particular element has the exact value then do the intended work:
不可以指向任何选择器,但是你可以使用if条件来检查特定元素是否具有确切的值然后执行预期的工作:
if($('.timeline-axis-grid').css('left') === "53.3095px"){
// do stuff here
}
#4
2
The only way is to filter your collection by testing properties that satisfy your need ...
唯一的方法是通过测试满足您需求的属性来过滤您的收藏...
$('div.timeline-axis-grid-minor').filter(
function(){
var $t = $(this);
return ($t.css('position') == 'absolute'
// && $t.css(... // Add conditions to satify your needs
);
}
);
#5
1
if($('div.timeline-axis-grid').css('left') === "53.3095px"){
////your code
}
Or
要么
if($('div.timeline-axis-grid').style.left === "53.3095px"){
////your code
}