2016-05-02 2 views
-1

私はこのコードを持っている:見出しのテキストを変更しますか?

HTML:

<button id='ro' class='ro'></button> 
    <button id='eng' class='eng'></button> 

JAVASCRIPT:

$('#ro').click(function(){ 
      $('h1').text('Bine a&#355i venit!'); 
      $('p1').text('Pathifier &#238&#351i propune s&#259 ajute tinerii din &#238ntreaga &#355ar&#259 s&#259 i&#351i g&#259seasc&#259 o facultate cu profilul dorit l&#259s&#226ndu-le libertatea s&#259-&#351i aleag&#259 ora&#351ul potrivit.'); 
      alert('ma-ta'); 
    }); 

    $('#eng').click(function(){ 
      $('h1').text('Welcome'); 
      $('p1').text('Pathifier s goal is to help teens all around Romania to choose the university that fits them best, also allowing them to find the perfect city which has that university '); 
    }); 

二つのボタンがページの言語を変更するためのものですが、私、彼らはありませんワーキング。どうして?私は何を間違えたのですか?

+0

なぜeをパラメータとして渡していますか? – Radmation

+0

ok、編集:D – VladJ

+0

これは私のために働く。あなたはjqueryを含んでいますか? – Radmation

答えて

-1

私のjavascriptのコード:

$(document).ready(function() { 

    //var cow = 'Check out this image <a href="http://link.com"><img src="http://image.com" style="border:2px solid #ccc;" /></a> and one with a width <a href="http://link.com"><img src="http://image.com" width="700" align="left" /></a>'; 
    $('#ro').click(function(){ 
     $('h1').text('Bine a&#355i venit!'); 
     $('p').text('Pathifier &#238&#351i propune s&#259 ajute tinerii din &#238ntreaga &#355ar&#259 s&#259 i&#351i g&#259seasc&#259 o facultate cu profilul dorit l&#259s&#226ndu-le libertatea s&#259-&#351i aleag&#259 ora&#351ul potrivit.'); 
     alert('ma-ta'); 
    }); 

    $('#eng').click(function(){ 
     $('h1').text('Welcome'); 
     $('p').text('Pathifier s goal is to help teens all around Romania to choose the university that fits them best, also allowing them to find the perfect city which has that university '); 
    }); 
}); 

私のhtml:

<!DOCTYPE html> 
<html lang="en"> 

<head> 

    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <meta name="description" content=""> 
    <meta name="author" content=""> 

    <title>One Page Wonder - Start Bootstrap Template</title> 

    <!-- Bootstrap Core CSS --> 
    <link href="css/bootstrap.min.css" rel="stylesheet"> 

    <!-- Custom CSS --> 
    <link href="css/one-page-wonder.css" rel="stylesheet"> 

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]> 
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> 
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> 
    <![endif]--> 

    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'> 


</head> 

<body> 

<button id='ro' class='ro'></button> 
<button id='eng' class='eng'></button> 

<h1>KLJLKJ</h1> 
<p>lkasjdflsj</p> 
<h1>KLJLKJ</h1> 
<p>lkasjdflsj</p> 
<h1>KLJLKJ</h1> 
<p>lkasjdflsj</p> 


<!-- jQuery --> 
<script src="js/jquery.js"></script> 

<!-- Bootstrap Core JavaScript --> 
<script src="js/bootstrap.min.js"></script> 



<!-- my js --> 
<script src="js/test.js"></script> 
</body> 

</html> 

これは動作します。 jQueryの後にjQueryとjsファイルが含まれていることを確認してください。

+0

簡潔にするため、すべての*エクストラ*を含めないでください。ブートストラップCSS/JS、あなたの*サーバー上のファイルへの相対リンク、Gooeleフォント、HTML5 shivs、respond.jsなど。ちょうどインラインでJavaScriptをインライン化してシンプルにして、あなたの例を別のサーバで簡単に外挿して(変更なしで)実行することができます。 – Marcus

関連する問題