Jump to content

Search the Community

Showing results for tags 'div innerHTML content replace'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. Hi, i really donĀ“t know how to solve this, or why it isn't working... first i try to grab all elements havung a specified class. no matter if it's 1 or 1000 elements. After that all of those elements will have assigned an eventListener which then calls the function to replace the content from the clicked element in another specified element. (by taking and replacing inner html). Usually i had the targetcontainer as 2nd argument in the eventlistener, but that didn't work at all. See for yourself what happens. Funny that when using the displayDate function everything works fine... var spieler = document.getElementsByClassName("smallCard"); var i; for (i = 0; i < spieler.length; i++) { console.log(this.innerHTML); spieler[i].addEventListener("click", ReplaceContentInContainer(spieler[i].innerHTML)); } function ReplaceContentInContainer(content) { var container = document.getElementById("fc"); container.innerHTML = content; } function displayDate() { document.getElementById("fc").innerHTML = Date(); } But like this it's working: { var spieler = document.getElementsByClassName("smallCard"); var i; for (i = 0; i < spieler.length; i++) { spieler[i].addEventListener("click", ReplaceContentInContainer); console.log(spieler[i]); } } function ReplaceContentInContainer() { document.getElementById("fc").innerHTML = this.innerHTML; } But i don't understand why !Maybe someone could help me ou by explaining this to me.
×
×
  • Create New...