Jump to content

empressia

Members
  • Posts

    1
  • Joined

  • Last visited

  • Days Won

    1

empressia last won the day on October 23 2020

empressia had the most liked content!

1 Follower

About empressia

  • Birthday 10/30/1983

Previous Fields

  • Languages
    Polish, English

Contact Methods

  • Website URL
    https://empressia.co/

Profile Information

  • Location
    Poland
  • Interests
    HTML, CSS, JavaScript, PHP, React.js, Vue.js, Symfony, PrestaShop, Sylius, WordPress, Joomla

empressia's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Hi! item is a function, not an object, so you must call it: linkElements.item(i).setAttribute("target", "_self") By the way, getElementsByTagName returns HTMLCollection and you can get single item also in this way: linkElements[i].setAttribute("target", "_self") Finally, you incorrectly compare whether the target equals _blank. You used "=" which means you are assigning this value. You must use "==" or "===" operator. Please refer to the MDN documentation. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality Corrected code and additionally the same example in ES6+ syntax https://jsbin.com/minufujiba/1/edit?html,js,console,output
×
×
  • Create New...