View Full Version : Need some javascript help

08-17-2011, 08:59 PM
function clickPost(el){
var im=el.parentNode.style.backgroundImage;
var sp0=im.split("/");
var sp1=sp0[sp0.length-1].split(".");

<div class="thumb" style="background-image: url('images/1.jpg');"><a href='javascript:void(0)' onclick='clickPost(this)'>

This code above snags the number from the background-image file, I changed my code around and I believe I need to go to a childnode now to grab the number from the img src but am having issues figuring it out. Thanks

Below is the current code for displaying the thumbs:

<div id="container">
<a href='javascript:void(0)' onclick='clickPost(this)'><div class="overlay"></div>
<div class="image"><img src="images/2.jpg" /></a></div>

08-17-2011, 11:26 PM
This is illegal HTML

<div id="container">
<a href='javascript:void(0)' onclick='clickPost(this)'>
<div class="overlay"></div>
<div class="image">
<img src="images/2.jpg" />

An anchor is an inline element and must not contain block level elements. On top of that your element nesting is flawed.