Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery function css [duplicate]

I want know if this script is bad, not working for me :

jQuery(".template_content_img").css({
    width: "50%",
    height: "150px",
    //// Here gives me error 
    font-size: "12px",
    margin-bottom: "23px",
});

I don´t know if the problem it´s is "width:200px" or "width","150px"

These are my dudes, by another side I see also many people use animate for this and no use css but why do you suppose the animate create effect and transformation of divs and by this only I need change somethings but it's not working.

Regards !!!

like image 604
user2501504 Avatar asked Sep 23 '26 23:09

user2501504


2 Answers

Check jQuery .css documentation

jQuery(".template_content_img").css({
    "width": "50%",
    "height": "150px"
});

jQuery(".template_img").css({
    "width": "70%",
    "height": "100px"
});

EDIT: If you want add font-size or margin-bottom, just use classic CSS attributes/values

jQuery(".template_content_img").css({
    "width": "50%",
    "height": "150px"
    "font-size": "12px",
    "margin-bottom": "23px",
});
like image 126
Shaddow Avatar answered Sep 25 '26 13:09

Shaddow


For multi-word CSS attributes, either use quotes:

"font-size": "12px",

or camelCase:

fontSize: "12px",

The object has to be a valid Javascript object literal, and delimiters like - are not allowed in unquoted property names.

like image 43
Barmar Avatar answered Sep 25 '26 12:09

Barmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!