Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

<span id="change">
    Stuff In Here
</span>

<script>
$("#change").on("mouseover", function () {
     $('#change').text("This is the new html");
});
</script>

The following doesn't work, as a jQuery noob, I'm not sure why.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
149 views
Welcome To Ask or Share your Answers For Others

1 Answer

Change this:

<script>
 $("#change").on("mouseover", function () {
   $('#change').text("This is the new html");
 });
</script>

Because you are not referencing anything. Try this:

<script>
  $(document).ready(function () {
    $("#change").mouseover(function () {
      $('#change').text("This is the new html");
    });
  });
</script>

Well, there was another error in the fiddle. You had not selected any jQuery version in the upper left corner. After updating, the code worked perfectly, and from this I concluded that you might have not linked the script in your website.

Try linking the script file in the head section of your layout (website)

Here have a look now: http://jsfiddle.net/afzaal_ahmad_zeeshan/HMhVn/3/

I have updated it, and it runs perfectly now :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...