0

I have my custom bg already. Also, I want to add a form field which will give to my visitors a choise to change it (they may add their custom BG url (any site) in to the form) + the result will store in the cookies. I know how to save any action in cookies, however I don't have any good example of how to change BG using form inputs.

Could any one help me please? I would apreciate any link on to a good example (which will support 1.9.1 version of Jquery) or your own example here. Thank you!

2 Answers 2

1

Try this one

<input>
<button>done</button>
<div class="bg_img"></div>


$('button').click(function(){
 var bg_url = $('input').val();
    console.log(bg_url)
    $('.bg_img').attr('style','background-image:url('+bg_url+')');
});

here is jsfiddle

Sign up to request clarification or add additional context in comments.

Comments

0

using jQuery on page load:

$(document).ready(function() {
  $('body').attr('background-image', here is your cookie value where you store the image url);
});

1 Comment

Yes, it's a basic start. But I need a lil bit more information about how to make it work with form inputs properly.

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.