Все, поняла, но не поняла, почему с функцией не работает, вот в код добавила как функцию:
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> </head> <body> <div class="noindex"> <div id="toolsHeading"> <div class="tools-dashboard clearfix"> <div class="mbrHomeHeader"> <div class="header-content"> <h1> <strong>Welcome</strong> MADAM BROSHKINA </h1> </div> </div> </div> </div> </div> <script> function iWantKnow() { var text1 = document.getElementById('content').getElementsByTagName('h1')[0].lastChild.data; return text1; } </script> <form> <p>Dear <script>document.write(iWantKnow());</script> , please enter valid phone number</p> </form> </body> </html> и не работает... |
mariaanina,
вам сюда http://learn.javascript.ru/ <!DOCTYPE HTML> <html> <head> <title>Untitled</title> </head> <body> <table width="100%" cellspacing="0" cellpadding="0" class="v16"> <thead> <tr> <th> <span style="font-size: 1.25em;" class="heading_v15 fl append-1">Security Questions</span> <a href="https://mysite.com" style="line-height: 1.2;" class="primary">Edit <span class="hiddenMessage"> your preference</span></a> </th> </tr> </thead> <tbody> <tr><td> Do you love white color? </td></tr> <tr><td> Do you love black color? </td></tr> <tr><td> Do you love green color? </td></tr> </tbody> </table> <script> var td = document.querySelectorAll('tbody td'); for (var i=0; i<td.length; i++) {alert(td[i].innerHTML)} </script> </body> </html> |
Цитата:
|
Цитата:
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> </head> <body> <div id="content" role="main"> <div class="noindex"> <div id="toolsHeading"> <div class="tools-dashboard clearfix"> <div class="mbrHomeHeader"> <div class="header-content"> <h1> <strong>Welcome</strong> MADAM BROSHKINA </h1> </div> </div> </div> </div> </div> <script> function iWantKnow() { var text1 = document.getElementById('content').getElementsByTagName('h1')[0].lastChild.data; return iWantKnow(); } </script> <form> <p>Dear <script>document.write(iWantKnow());</script> , please enter valid phone number</p> </form> </body> </html> а все равно, блин, не работает |
Цитата:
return iWantKnow(); Ну а вот это зачем? Было же правильно: return text1; |
mariaanina,
у вас какой-то праздник !!! 26 строка зачем сменили и где закрывающий тег у id = 'content' |
Правка, закрывающий тег добавила, но не воркает...
\ <!DOCTYPE HTML> <html> <head> <title>Untitled</title> </head> <body> <div id="content" role="main"> <div class="noindex"> <div id="toolsHeading"> <div class="tools-dashboard clearfix"> <div class="mbrHomeHeader"> <div class="header-content"> <h1> <strong>Welcome</strong> MADAM BROSHKINA </h1> </div> </div> </div> </div> </div> </div> <script> function iWantKnow() { var text1 = document.getElementById('content').getElementsByTagName('h1')[0].lastChild.data; return text1(); } </script> <form> <p>Dear <script>document.write(iWantKnow());</script> , please enter valid phone number</p> </form> </body> </html> |
Цитата:
Цитата:
|
Все, поняла, спасибо огромнейшее за потраченные нервы :)
|
Часовой пояс GMT +3, время: 09:07. |