Guest User

Untitled

a guest
May 9th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. how to apply CSS styles in current document recieved from AJAX request?
  2. #id1{something:something}
  3. #id2{something:something}
  4. #id3{something:something}
  5. ...etc ect
  6.  
  7. <link rel="stylesheet" type="text/css" href="..." />
  8.  
  9. var url = "......"; // including parameters
  10.  
  11. var script = $('<link>', {
  12. rel: 'stylesheet',
  13. type: 'text/css',
  14. href: url
  15. }).appendTo(document.head);
  16.  
  17. var data = {id1: {something: something}, id2: {something: something}, id3: {}}
  18.  
  19. $.each(data, function(index, item) {
  20. $('#' + index).css(item);
  21. });
  22.  
  23. <div id="result"></div>
  24.  
  25. $('head').append('<style> #result { background-color: orange; } </style>');
Advertisement
Add Comment
Please, Sign In to add comment