views:

113

answers:

2

i want to crate style class in java script tags

and class will be like this

     #file-ok {
        background-image: url(+   json.get('filename')   +);
     }

actually json.get('filename') will be name of file for background and will return from php file.

is this possible...?

+1  A: 

You can get your image filename and then set it as the background of the #file-ok element when the Ajax request ends:

$(function () {
  $.get("file.php", function(data){
    $('#file-ok').css('backgroundImage', 'url(' + data.filename + ')');
  });
});
CMS
A: 

The simplest way is to apply an inline style, but this is no good if you need to apply this to multiple elements then look at using setProperty() on a CSSRule.

You can find a great write up here - http://www.quirksmode.org/dom/changess.html

Phunky