更改标题文本

Changing heading text?

本文关键字:文本 标题      更新时间:2023-09-26

我有这个代码:

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 ');
    });

这两个按钮是为了改变页面的语言,但我认为它们不起作用。为什么?我做错了什么?

我的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文件。