How can I get content of div class="dpBibHoldingStatement" ? It can't be used with getElementByClass, because there are several same classes in the html. I can't show all the code.
<div class="dpBibTitle">
<!-- please read c1063106, c1063117, c1044421, c1060576a before changing title -->
<a id="recordDisplayLink2Component_0" href="/iii/encore/record/C__Rb4101617__Sapple__P0%2C1__Orightresult__X5?lang=eng&suite=pearl">
The Apple experience : the secrets of delivering insanely great customer service</a>
/ by Carmine Gallo
</div>
<div class="dpBibAuthor">
<!-- author -->
<a id="authorDisplayLinkComponent_0" href="/iii/encore/search/C__SGallo%2C+Carmine.__Orightresult?lang=eng&suite=pearl">
Gallo, Carmine.</a>
</div>
<div class="dpBibHoldingStatement">
Circulation Collection
HF5415.5 .G356 2012
DUE 10-03-13OFF CAMPUS
</div>
How can I get content of div class="dpBibHoldingStatement" ? It can't be used with getElementByClass, because there are several same classes in the html. I can't show all the code.
<div class="dpBibTitle">
<!-- please read c1063106, c1063117, c1044421, c1060576a before changing title -->
<a id="recordDisplayLink2Component_0" href="/iii/encore/record/C__Rb4101617__Sapple__P0%2C1__Orightresult__X5?lang=eng&suite=pearl">
The Apple experience : the secrets of delivering insanely great customer service</a>
/ by Carmine Gallo
</div>
<div class="dpBibAuthor">
<!-- author -->
<a id="authorDisplayLinkComponent_0" href="/iii/encore/search/C__SGallo%2C+Carmine.__Orightresult?lang=eng&suite=pearl">
Gallo, Carmine.</a>
</div>
<div class="dpBibHoldingStatement">
Circulation Collection
HF5415.5 .G356 2012
DUE 10-03-13OFF CAMPUS
</div>
Share
Improve this question
edited Jun 17, 2013 at 9:10
Darren
70.9k24 gold badges141 silver badges145 bronze badges
asked Mar 6, 2013 at 18:47
helloeveryonehelloeveryone
391 silver badge6 bronze badges
3 Answers
Reset to default 4Give the div an ID and use innerHTML
:
<div id="yourDiv">
Content
</div>
Then using JavaScript do:
var contents = document.getElementById("yourDiv").innerHTML;
alert(contents);
First of all, it's not getElementByClass
. It's getElementsByClassName
.
When you run document.getElementsByClassName("label-key")
on this page at developer tools, it'll show you an array of label-key
items. You can get any item that you want from that array.
You can either use document.getElementsByClassName[n]
to target the (n-1)th element on the page, or you attach an ID to it and use document.getElementById(id)
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745493181a4630077.html
评论列表(0条)