Web Analytics Made Easy -
StatCounter Need some javascript help - CodingForum

Announcement

Collapse
No announcement yet.

Need some javascript help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need some javascript help

    Code:
    <script>
    function clickPost(el){
    	var im=el.parentNode.style.backgroundImage;
    	var sp0=im.split("/");
    	var sp1=sp0[sp0.length-1].split(".");
    	document.getElementById("formInp").value=sp1[0];
    	document.F.submit();
    }
    </script>
    Code:
    <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:
    Code:
    <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>
    </div>

  • #2
    This is illegal HTML
    Code:
    <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>
    </div>
    An anchor is an inline element and must not contain block level elements. On top of that your element nesting is flawed.

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎