-1

So This is the html I wrote:

<html>
<head>
<script type="text/javascript" src="language.js"></script>
</head>
<body>
   <div class="eng"> Change this English sentence </div>
   <span id="frn" style="text-decoration:underline">French</span>
</body>

Meanwhile, the jQuery:

$(document).ready(function(){
    $("#frn").on('click', function(){
        $(".eng").html("modifier cette phrase en anglais");
    });
});

I use Microsoft Expression Web 4.0.1460.0 to generate this codes. So, what I want to do is change the text on a div when user click on span. In this case, change a defined text from english to french when someone click on span with text French and ID #frn.

However, when I preview this on Google Chrome. It didn't work. By clicking the span, nothing happened. Please kindly help me on this.

2 Answers2

1

HI check the updated code you havent include the jquery library , this works fine.

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#frn").on('click', function(){
        $(".eng").html("modifier cette phrase en anglais");
    });
});
</script>
</head>
<body>



  <div class="eng"> Change this English sentence </div>
   <span id="frn" style="text-decoration:underline">French</span>

</body>
</html>

Happy Coding

Gayathri Mohan
  • 2,924
  • 4
  • 19
  • 25
-1

It is working fine in this JSFiddle

https://jsfiddle.net/5g3decLd/1/

Also, I would suggest to change html() to text()

$(".eng").text("modifier cette phrase en anglais");
SenthilKumarM
  • 119
  • 1
  • 8