jQuery - 鼠标悬停在更改文本上 [英] jQuery - On Mouse Over Change Text
问题描述
< span id =change>
这里的东西
< / span>
< script>
$(#change)。on(mouseover,function(){
$('#change')。text(This is the new html);
} );
< / script>
以下不起作用,作为jQuery noob,我不知道为什么。
更改此:
<脚本>
$(#change)。on(mouseover,function(){
$('#change')。text(This is the new html);
} );
< / script>
因为你没有引用任何东西。试试这个:
< script>
$(document).ready(function(){
$(#change)。mouseover(function(){
$('#change')。text(This is新的html);
});
});
< / script>
好的,小提琴还有另一个错误。你没有在左上角选择任何jQuery版本。更新后,代码完美运行,并从中得出结论,您可能未链接到您网站的脚本。
尝试链接 文件放置在布局(网站)的 我已经更新了它,现在它完美运行:)脚本
头部
部分中。现在: http://jsfiddle.net/afzaal_ahmad_zeeshan/HMhVn/3/
<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.
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 :)
这篇关于jQuery - 鼠标悬停在更改文本上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!