Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142100

Using class/id to edit innerHtml in JavaScript not working

$
0
0

Hi i tried adding class and id to my innerHtml text with Javascript but after doing it, it didn't display the text it was supposed to display onclick So I want to know how i can edit texts there without using class or id This is my code below

<!DOCTYPE html>
<html lang="en">
    <body>
        <button id="myb">AAAAAAA</button>
        <table id="t01">
            <tr>
                <th></th>
                <th><p>Monday</p></th> 
                <th><p>Tuesday</p></th>
                <th><p>Wednesday</p></th>
                <th><p>Thursday</p></th>
                <th><p>Friday</p></th>
                <th><p>Saturday</p></th>
                <th><p>Sunday</p></th>
            </tr>
            <tr>
                <td class="black-mamba"><p>8:00AM</p></td>
                <td><p>Smith</p></td>
                <td><p>50</p></td>
                <td><p>Smith</p></td>
                <td><p>50</p></td>
                <td><p>Smith</p></td>
                <td><p>50</p></td>
                <td><p>Smith</p></td>
            </tr>
        </table>
        <script type="text/javascript">
           document.getElementById("myb").onclick = function() {
           document.getElementById("t01").innerHTML = "<table><tr><th>Firstname</th><th>Lastname</th> <th>Age</th></tr><tr><td>Jill</td><td>ggggSmith</td><td>50</td></tr><tr><td>Eve</td><td>Jackson</td><td>94</td></tr><tr><td>John</td><td>Doe</td><td>80</td></tr></table>";
                }
       </script>

    </body>
</html>

Viewing all articles
Browse latest Browse all 142100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>