0
<div __jx__id="___$_15" style="position: absolute; overflow: hidden;">

I would like to modify the above div by adding display:block to the style using javascript

<div __jx__id="___$_15" style="display:block;position: absolute; overflow: hidden;">

I tried using

function getAllElementsWithAttribute(attribute)
{
  var matchingElements = [];
  var allElements = document.getElementsByTagName('*');
  for (var i = 0; i < allElements.length; i++)
  {
    if (allElements[i].getAttribute(attribute))
    {
      // Element exists with attribute. Add to array.
      matchingElements.push(allElements[i]);
    }
  }
  return matchingElements;
}

getAllElementsWithAttribute('__jx__id="___$_15);

adapted from

Get elements by attribute when querySelectorAll is not available without using libraries?

the selector itself is not working let alone add the additonal display:block to the div

Community
  • 1
  • 1
user2625447
  • 9
  • 2
  • 6

2 Answers2

1

The name of your attribute is __jx__id and the value is ___$_15.

so try: getAllElementsWithAttribute("__jx__id");

If you also want to filter by the value of the attribute then you'll need to pass it in seperately: getAllElementsWithAttributeAndValue("__jx__id", "___$_15");

Halcyon
  • 57,230
  • 10
  • 89
  • 128
0

A lot easier with jQuery:

$("div[__jx__id]").css({display:block});

or even

$("div[__jx__id]").show();
deitch
  • 14,019
  • 14
  • 68
  • 96