how to check the type of element in jquery Edit

Murugan Andezuthu Dharmaratnam | 16 September 2020 | 715

In the javascript code, I wanted to update the src if the selected element is an Image. Check the jquery / javascript code below to find the type of element.

$(".classname")[0].tagName
or 
$("#yourid")[0].tagName

The above code returns IMG if the selected element is an image