Mit Javascript / Jquery zu ändern, text im div auf die Schaltfläche klicken

hier ist das array

var copyText= [
'this is the first line',
'Simply put, the second line',
'impressed by the third line.'
    ];

Diese nicht funktionieren ...

$("#thisbutton").click(function () {
$("#thetext").innerHTML("meow meow");
});

oder

$("#thisbutton").click(function () {
$("#thetext").innerHTML(copyText[1]);
});

oder

$("#thisbutton").click(function () {
$("#thetext").text(copyText[1]);
});


$("#thisbutton").click(function () {
$("#thetext").html(copyText[1]);
});

Was ich bin fehlt? thks.

  • Poste bitte den rest der Quellcode auf der Seite. Auch, werden Sie wahrscheinlich wollen, wickeln Sie das ganze in $(function(){ //code hier });
  • danke, ja das ist es. was ist mit href und links, wie kann ein javascript-array zugegriffen werden? <!DOCTYPE html> <html> <head> </head> <body> <script type="text/javascript"> $(function() { var htmlLinks= [ 'cnn.com', 'youtube.com', 'facebook.com' ]; }); </script> <ein href="<script type="text/javascript">htmlLinks[0];</script>" target="_blank"> link1 </a> \ <ein href="<script type="text/javascript">htmlLinks[1];</script>" target="_blank"> link2 </a> \ <ein href="<script type="text/javascript">htmlLinks[2];</script>"target="_blank"> link3 </a> </body> </html>
InformationsquelleAutor windsurf88 | 2010-11-28
Schreibe einen Kommentar