I have issues animating the font-size on element mouseenter:
HTML :
<p>Hello!</p>
Javascript :
$(document).ready(function () {
("p").mouseenter(function () {
("p").animate({
"font-size": "50px"
});
});
("p")
should be $("p")
You're missing an });
and you're not using the jQuery library
$(document).ready(function () {
$("p").mouseenter(function () {
$(this).animate({"font-size": "50px"});
});
});
A slightly nicer way to write the same would be:
jQuery(function($) { // DOM ready shorthand
$("p").mouseenter(function() {
$(this).animate({ fontSize : 50 });
});
});
Remember to always keep reference to the targeted Object Element $(this)
to get the desired result.
you must use $ sign in your code try this code. i tested.
$(document).ready(function () {
$("p").mouseenter(function () {
$(this).animate({
"font-size": "50px"
});
});
});
You are missing the }); and $ signs, and the jQuery library in your fiddle.
$(document).ready(function(){
$("p").click(function(){
$(this).animate({fontSize:"30px"});
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.