-2

I need to set the iframe role property.

const iframe = document.createElement('iframe');

but I am not getting iframe.role property

Shobha
  • 95
  • 2
  • 8
  • Please see the question, it have enough information. – Shobha Sep 30 '20 at 09:18
  • I don't want to argue with you, i got the answer. – Shobha Sep 30 '20 at 09:37
  • Please visit the [help], take the [tour] to see what and [ask]. ***[Do some research](https://www.google.com/search?q=javascript+add+role+to+element&oq=javascript+add+role+to+element)***, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output using the `[<>]` snippet editor. – mplungjan Sep 30 '20 at 09:43

1 Answers1

1

Use setAttribute method.

const iframe = document.createElement('iframe')
iframe.setAttribute('role', 'banner')

console.log(iframe) // <iframe role="banner">...</iframe>
Magiczne
  • 1,540
  • 2
  • 13
  • 21