Home > Article > Web Front-end > How to write css style in jq
The method is as follows: Generally, the style needs to be loaded when the page is initialized, so the ready() method is used, and the syntax format is "$(document).ready(function)". The ready event occurs when the DOM has loaded and the page (including images) has been fully rendered.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
The method of writing css style in jquery is as follows: Generally, the style must be loaded when the page is initialized, so use the ready() method
$(document).ready(function(){ $("table tr td").css({ "height":"25px", }) $("span").css({ "color":"#337ab7", "font-size":"13px", }); });
When the DOM (Document Object Model) has been loaded, and the page The ready event occurs when the object (including the image) has been fully rendered.
Since this event occurs after the document is ready, it is a good practice to place all other jQuery events and functions in this event. Just like in the example above.
ready() function specifies the code to be executed when the ready event occurs.
ready() function only works on the current document, so no selector is required.
The following three syntaxes are allowed:
Grammar 1
$(document).ready(function)
Grammar 2
$().ready(function)
Grammar 3
$(function)
Tip: ready( ) function should not be used with a12867977b4e8455fcea60d618d8572e.
Recommended learning: css video tutorial
The above is the detailed content of How to write css style in jq. For more information, please follow other related articles on the PHP Chinese website!