O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required