javascript - Get elements 'tag name' by searching Class name -
i'm trying element tag name associated element class name.
i know can these 2 lines of code class name , tag name.
document.getelementsbytagname("regeneratepostnatal"); document.getelementsbyclassname(returnedpatientid);
i'm asking if there way of doing below tag name belongs element class name?
document.getelementsbyclassname(returnedpatientid).tagname
example
var element = document.getelementsbyclassname("oneid")[0].tagname; document.getelementbyid("returnedvalue").innerhtml = element; var element2 = document.getelementsbyclassname("oneid")[0].nodename; document.getelementbyid("returned2value").innerhtml = element2;
<a class="oneid" name='regeneratepostnatal'>click</a> <div id="returnedvalue"></div> <div id="returned2value"></div>
i'm trying name attribute value it'll show "regeneratepostnatal"
are trying attribute name value?
var element = document.getelementsbyclassname("oneid")[0].getattribute('name'); document.getelementbyid("returnedvalue").innerhtml = element;
<a class="oneid" name='regeneratepostnatal'>click</a> <div id="returnedvalue"></div>
Comments
Post a Comment