Skip to main content

Posts

Showing posts with the label jQuery styling

Intro to jQuery: The Power Of jQuery Selectors

How to select element? In jQuery, we select an element with $() . $("Selector Name") Selecting with "$" is very similar to querySelector and querySelectorAll. In that we provide a CSS style selector. Then, jQuery will return all matching element. I updated the jQuery Demo HTML page a little by adding a <a> tag and id "test" in the list. If I want to select the h1, I just need to type $("h1")[0] in the console, and it will return us the h1. If I want to select the link, I just need to type $("a")[0] , and it will return the link. If I want to select the list with special id, I just need to type $("#test")[0] , and it will return that list. Moreover, selecting element with the dollar sign in jQuery will return a list even if there's only one item. And it is much shorter and easier to wirte syntax. How to manipulate style? The .css() method is jQuery's interface to st...