J. Doe J. Doe - 9 months ago 49
jQuery Question

OnClick change color from another element

I currently have this code

$('well').click(function () {
$('span').css('background-color', '#000').css('color', '#000');

and I'm trying to make when I click on this "well" (from bootstrap) the color to a span from this well to be changed..


if well is class than use .well

$('.well').click(function () {
    $('span').css({backgroundColor:'#000', color:'#000'});

if well is id than use #well

$('#well').click(function () {
    $('span').css({backgroundColor:'#000', color:'#000'});

Also make sure to wrap your code in DOM ready:

jQuery(function( $ ) { // DOM is now read and ready to be manipulated and $ alias secured

   // Your $ jQuery code here