Reputation: 281
I have looked high and low for a solution and I have found many that come close to an answer but cannot find something that solves my exact problem.
I have jquery removing display: none;
style attribute.
This sets the style attribute equal to style=""
as there are no other styles set inside the style attribute.
How do i test and build an array of all the elements that have the style attribute set to style=""
NOTE the elements in question are part of a table with the id of #returnedTable
and the td elements look like <td style="" rel="22">
I am trying to return an array of the data contained in the rel attribute for each td element that has a style attribute set to style=""
. Note it will be mixed in with td elements that look like
<td style="display: none;" rel="24839">
Upvotes: 3
Views: 2028
Reputation: 342635
You can get all elements with style set to "" like this:
var eles = $("*[style='']");
If you just want the rel attribute values, you can do:
var arr = $("*[style='']").map(function() {
return $(this).attr("rel");
}).get();
Upvotes: 2
Reputation: 2603
Why not give those elements a particular class with jquery? You could easily build an array of their rel
values then.
var rels = [];
$('#returnedTable tr td.myClass').each(function(){
rels.push($(this).attr("rel"));
});
Upvotes: 1
Reputation: 338228
var rels = [];
$("#returnedTable td[style='']").each(function () {
rels.push( $(this).attr("rel") );
});
Upvotes: 1