Use a string concatenation inside of the css argument
$("body").css("background-image", 'url('+$.cookie("_usci")+')');
//don't forget to close your css call as Jonathan notes ^
Вопрос
My jQuery:
$(function() {
$("#change-background").on('submit', function(e) {
var src = $(this).find("input").val();
$.cookie("_usci",src);
//NOT HERE$("body").css("background-image", 'url($.cookie("_usci"))';
});
//BUT HERE!! otherwise it will not work
});
The url need to be within these ' or these " but then the cookie will not be used good, how can I solve this?
Решение 2
Use a string concatenation inside of the css argument
$("body").css("background-image", 'url('+$.cookie("_usci")+')');
//don't forget to close your css call as Jonathan notes ^
Другие советы
Have you tried this?:
$("body").css("background-image", 'url(' + $.cookie("_usci") + ')';