Adding Borders

$("ul").on("click", function(){   $(this).css({"border":"3px groove black"}); }); $("li").on("click", function(){   $(this).css({"border-style":"dotted",                "border-size":1,                "border-color":"blue"}); });

Another useful style that can be programmatically applied to elements is borders. Borders give you a way to highlight specific elements on the page or just change the look of things.

You can change the CSS attributes that apply borders to elements in jQuery using the .css(property, value) or .css({property:value, property:value...}) method.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.