blackHawk
blackHawk

Reputation: 6307

How to convert object into string

So I was using getElementById method and consoled it when I'm consoling with string it just displays string object like this [Object] i want to display it as Object

var element = document.getElementById('input');
console.log("the view element "+ element );

Upvotes: 1

Views: 53

Answers (3)

Will
Will

Reputation: 3251

console.dir is your friend.

var el = document.querySelector('div');
console.dir(el);
<div>Stuff</div>

Upvotes: 0

Michael Warner
Michael Warner

Reputation: 4247

you can try

console.log ('text', element)

enter image description here

Upvotes: 1

Naresh Teli
Naresh Teli

Reputation: 138

console.log(element);

//Now you can explode the object

Upvotes: 0

Related Questions