我正在尝试在tampermonkey中编写一个脚本,该脚本打印/插入一个值,计算每个列表的$ per ft ft。(Price / Total Sq Ft。)。我没有javascript经验:
网页: http://www.utahrealestate.com/search/map.search
HTML的相关部分(其中一个列表:)
<div id="mls-inline-1420899" class="listing_container">
<div class="listing-wrapper-table">
<div class="listing-wrapper-row">
<div class="listing-container-desktop">
<div class="listing-wrapper-cell">
<img src="http://assets.utahrealestate.com/photos/280x210/1420899_6faef96a263f4613b6b300cc915a9767_710733.jpg" class="listing-img" alt="MLS #1420899 Photo">
</div>
<div class="listing-wrapper-cell aligned-top">
<div class="inline_info">
<p class="status">
<i class="icon icon-circle status-1"></i> Active </p>
<h3>$249,000</h3>
<div class="list-info-content">
135 S 300 E <br>
Provo, UT 84606 </div>
<div class="list-info-content">
5 bds •
2.00 ba •
2026 sqft<br>
Built: 1914 • MLS #: 1420899 </div>
<p class="inline_agent">Agent: Chase Leavitt</p>
<p class="inline_brokerage">RE/MAX Equity</p>
</div>
</div>
</div>
<div class="listing-container-handheld">
<img id="img_1420899" class="listing-img" src="http://assets.utahrealestate.com/photos/640x480/1420899_6faef96a263f4613b6b300cc915a9767_710733.jpg" alt="MLS #1420899 Photo">
<div class="listings-info" style="display: block;">
<div class="listings-info-left-col">
<span>$249,000</span>
<p class="listing-address">135 S 300 E</p>
<p class="listing-address-csz">Provo, UT 84606</p>
</div>
<div class="listings-info-right-col">
<div class="border"><span>5</span><br>Beds</div>
<div class="border"><span>2.00</span><br>Baths</div>
<div class="end"><span>2026</span><br>Sq.Ft.</div>
<p>#1420899</p>
</div>
<p class="inline_brokerage">RE/MAX Equity</p>
</div>
</div>
</div>
</div>
</div>
为了实现这一目标,我写了一些我需要完成的事情:
这是我到目前为止所拥有的。随时提供任何指示,链接或建议。我正在更新这个。谢谢你的帮助!
(#1)每个列表的值都在h3标记内。我想我需要使用find来获取h3标签的值:
.find('h3')
(#4)我想我可以使用appendChild输出原始sq ft值旁边的新值。仍在努力:
document.getElementById('list-info-content').appendChild(dollarPerSqFt);
(#5)循环开始.list-info-content类:
var find_class = document.getElementsByClassName('list-info-content');
for (var i = 0, i++) {
find_class[i].innerHTML = {do something to} find_class[i].innerHTML ;
}