Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Retrieve a div inside a div
01-22-2013, 09:10 PM #1
- Join Date
- Jan 2013
- Thanked 0 Times in 0 Posts
Retrieve a div inside a div
I've written a Greasemonkey script to replace the Firefox title bar at woot.com with the item, price, and % left - http://userscripts.org/scripts/show/137091 The problem is that it only works on the main woot-off page - if home.woot is also having a woot-off, you still get the item name from the main page.
Here is the source at home.woot:
<div class="offer woot-off "> <a class="info" href="http://firstname.lastname@example.org/daily"> <div class="label">It's a Woot Off</div> <div class="title">Smith's Electric Knife Sharpener</div> <div class="price"> <span class="price">$39.99</span> <span class="list-price">$99.99</span> <span class="percentage">60% off <span class="list-price-label">List Price</span></span> </div>
var subpageItem = document.getElementsByClassName("offer woot-off ").getElementsByClassName("title").innerHTML;
01-22-2013, 09:54 PM #2
- Join Date
- Sep 2005
- Sydney, Australia
- Thanked 718 Times in 707 Posts
The problem you have is that the top div in your HTML contains two classes "offer" and "woot-off" but you are searching for "offer woot-off ") which is an invalid class name because class names cannot contain spaces. Because it is invalid that nodelist will be empty.