javascript - JQuery apply css stored in variable -


I have a div that needs to be styled using CSS styles stored in a variable. Such as:

  var styles = 'font-weight', 'bold' '$' ('div'). CSS (style);  
  & lt; Script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" & Gt; & Lt; / Script & gt; & Lt; Div & gt; The Div Be Towled & lt; / Div & gt;  

It shows what I have to do, but it will not work. Someone has any ideas. Thank you.

Try,

  var styles = {'font-weight ':' Bold '}; $ ('Div'). CSS (style); Passing the  .css ()  function to  

string argument. And it is not a valid signature supported with .css () a style value

  var styles = {'font-weight': 'bold'}; $ ('Div') CSS (style);  
  & lt; Script src = "https: / /ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> & Lt; Div & gt; The Div Be Towled & lt; / Div & gt;  


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -