Javascript DOM HTML Bdo Object create

Introduction

We can create a <bdo> element by using the document.createElement() method:

var x = document.createElement("BDO");

Click the button to create a BDO element with some text that goes right-to-left.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from  www . ja  v  a2  s  . com
  var x = document.createElement("BDO");
  var t = document.createTextNode("This text will go right-to-left.");
  x.setAttribute("dir", "rtl");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related