0

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...?

2 Answers 2

1

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 + ')');
  });
});
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.