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
Post a Comment