Change CSS properties on click

后端 未结 8 2332
情话喂你
情话喂你 2020-11-29 22:53

I am trying to change the CSS of one element on click of another element. I\'ve searched a lot but nothing works perfectly. Currently I am using the below code, but it doesn

8条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 23:55

    In your code you aren't using jquery, so, if you want to use it, yo need something like...

    $('#foo').css({'background-color' : 'red', 'color' : 'white', 'font-size' : '44px'});
    

    http://api.jquery.com/css/

    Other way, if you are not using jquery, you need to do ...

    document.getElementById('foo').style = 'background-color: red; color: white; font-size: 44px';
    

提交回复
热议问题