⊗jqBsCPH 11 of 113 menu

CSS jQuery hyphenated properties

Let the property, as is often the case in CSS, consist of several words separated by hyphens:

<p class="www">text</p>

In this case, there are no problems - it is written in Javascript code in the same way as in CSS:

$('.www').css('font-size', '20px');

If you want to set several CSS properties, you can pass an object as a parameter to the css method, the keys of which will be the CSS properties, and the values ​​of the object will be the values ​​of the CSS properties:

$('.www').css({color: 'red', font: '12px Arial'});

However, there will be problems with properties like font-size - you need to write not font-size, but fontSize:

$('.www').css({color: 'red', fontSize: '12px'});

If you don't really like doing this, put the font-size key in quotes:

$('.www').css({color: 'red', 'font-size': '12px'});

As you can see, jQuery gives you different options for using methods depending on your preferences. Use whatever you are most comfortable with.

All h3 make bold text green.

Make all h2 blue and font-size: 30px.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline