Guest User

Untitled

a guest
Aug 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. jQuery CSS appending with no effect
  2. $('body').append('<style type="text/css"> body {background:red;} </style>');
  3.  
  4. edit : function(page) {
  5. $.ajax({
  6. data : {
  7. 'edit' : page
  8. },
  9. success : function(i){
  10. var html = jQuery.parseJSON(i);
  11.  
  12. $('#editPageListContainer, #editPreview').remove();
  13.  
  14. var script = document.createElement('script');
  15. script.type = 'text/javascript';
  16. script.text = html.js;
  17.  
  18. document.body.appendChild(script);
  19.  
  20. $('body').append('<style type="text.css">' + html.css + '</style>' + html.php);
  21. }
  22. });
  23. }
  24.  
  25. $('body').css('background', 'red');
  26.  
  27. $("head").append("<style> body {background:red;}</style>");
  28.  
  29. $.ajax({
  30. url: "url",
  31. async:false,
  32. success: function(css) {
  33. $("head").append("<style>"+css+"</style>");
  34. }
  35. });
  36.  
  37. $('body').attr('style', 'background:red');
Add Comment
Please, Sign In to add comment