How to change css of element using jquery

Tags: jquery,html,css

Problem :

I have defined a CSS property as

#myEltId span{
  border:1px solid black;

On clicking a button, I want to remove its border.

$('#button1').click(function() {
  // How to fetch all those spans and remove their border

Solution :

Just use:

        $('#myEltId span').css('border','0 none transparent');

Or, if you prefer the long-form:

        $('#myEltId span').css({
            'border-width' : '0',
            'border-style' : 'none',
            'border-color' : 'transparent'

And, I'd strongly suggest reading the API for css() (see the references, below).


    CSS Howto..

    How to get two divs the same height depending on which one has the bigger height in CSS [duplicate]

    How to override parent containers width property in CSS [duplicate]

    How to change the text-color of element after clicking it?

    Font-awesome not properly displaying on Firefox / how to vend via CDN?

    Ruby Command Line: How can I send the CTRL-C command via text in the command line?

    How to add 10 pixels to a dynamic top position in CSS using SASS

    VIM: How to autocomplete in a CSS file with tag ids and class names declared in HTML file

    How to select 3rd 'a' tag in a list for RSpec test?

    Css positioning: how to position a block/paragraph under another

    How to create a underline with small break in middle with css?

    How to set outline without using CSS outline property?

    How can I make this menu using only ul, li and css?

    How to override a part of the style in the site.master page?

    How to let css selector exclude an element?

    How can I set the CSS class of an element in a Rails view?

    How can I make make css transition happen when applying width through javascript

    How can I anticipate which type of CSS selector will work?

    How can I use CSS pseudo-classes with GWT's UiBinder?

    Chrome & Firefox not rendering bold font-weights of Avenir, but Safari does! How to fix?

    HTML/CSS/JAVASCRIPT : How to move an element and not show scrollbars

    How can I add a scrollbar to a DIV that contains a table?

    How to change CSS of an element on hide/show of another element(without custom events)?

    How to vertically align lists when one li is a div

    How to do make CSS Toggle like this? [closed]

    How to get cross browser compatibility in Print on page from all browsers?

    How to hide this element using CSS or JQuery

    how to set css for Zend form?

    How to display image in sidebar-wrapper css class

    How do I make the HTML Slider with CSS stay in the box?

    How can I make a button-link, as Like in Facebook?