はじめに
画像アドレスを入力することで、
背景画像を動的に変更する方法について書いていきます。
こちらのサイトで実装しています。 http://fffbookmark.herokuapp.com/
実行
基本となるビューファイルは次のようにします。
.body = text_area "object_name", {class: "wall-url"},{id: "wall-url"} .wall-btn 画像を変える
texr_area
が画像アドレスを張り付ける部分で、.w
all-btn
を押したら画像を変えるものとします。
次にJavaScriptです。(jQueryで書いています)
$(function(){ $(".wall-btn").on("click",function(){ }) });
これで、.wall-btn
をクリックした時に発火する関数ができました。
次は、処理の内容を書いていきます。
$(function(){ $(".wall-btn").on("click",function(){ var image = $("#wall-url").val(); }) });
これでテキストエリアに入力された画像アドレスを取得し、変数image
に代入できます。
テキストエリアのid
がwall-url
となっているので、#wall-url
の中身を取得するようにすればよいわけです。
最後に、背景画像を取得した画像アドレスのものに変更します。
$(function(){ $(".wall-btn").on("click",function(){ var image = $("#wall-url").val(); $(".body").css('backgroundImage',`url("${image}")`); }) });
注意するところは、background-image
を変更する処理ですが、
ここではbackgroundImage
となっているところです。-
がなくなって、直後の文字が大文字になっているわけですね。
url("${image}")
の部分は、''
で囲むと${image}
がただの文字列と表示されるので、この表記にしています。
また、url(${image})
としてもエラーになるので、必ず""
をつける必要があります。
コメント
21522 cute blonde teen kenzie reeves pulls her panties down around ankles http://norfolkonlinenews.worldsecuresystems.com/BannerProcess.aspx?ID=23298&URL=https%3a%2f%2fmichelejullian.info%2fcock%2f16547-sexy-babe-brea-lynn-spreading-wide-open.php
17704 gorgeous teacher india summer strips in the classroom https://career-navi.sendenkaigi.com/application/application_regist.jsp?job_id=88882&medium_application_pc_url=https%3a%2f%2fmichelejullian.info%2fanal%2f11864-skinny-doll-tries-anal-in-extra-spicy-home-fuck.php&rewrite_flg=1
18551 lovely babes lilly ford and eva notty have passionate lesbian sex http://www.mauieldorado.net/ViewSwitcher/SwitchView?mobile=True&returnUrl=https%3a%2f%2fmichelejullian.info%2fmodel%2f15250-femjoy-rosalin-feel-the-sun.php
82 solo teen blonde model with glasses fingers herself https://prezza.net/wp-content/plugins/abredirect/redirect.php?creative=p1852&url=https%3a%2f%2fmichelejullian.info%2fcock%2f21280-jason-connor-chris-little-naughty-straight-lad-gets.php
20991 anal sweet ass hot buttholes cute starfish browneye anus http://data.explorestlouis.com/scripts/memberLinks.asp?m=312&t=michelejullian.info/anal/5942-latina-liandra-andrade-anal-gaping-threeway-legalporno.php
3506 blonde girl on the floor casy http://www.whooshusa.com/ebayout.php?link=https%3a%2f%2fmichelejullian.info%2fpussy%2f23531-pink-haired-candy-elektra-masturbates-her-horny-wet.php
21808 huge dick in tight teen asshole hot young teens virgin https://go.publicacionesprofesionales.es/default.aspx?clk=7630bd6294ace665886696717bbfac98&url=michelejullian.info/babe/10251-aida-to-play.php
25001 bottomless and hairy mia xhamster https://akcion.hu/projectSetup/link.php?ret=/2838-billiard-forralt-borral&open=https://michelejullian.info/amateur/20162-amateurs-spreading-their-legs-vol.php
9553 amateureuro amateur teen angelica loves hardcore sex http://blackseafleet-21.com/link.php?https://michelejullian.info/anal/10738-amber-rayne-anal-gaping-with-als-rocket.php
22555 julie berdu spread and her anal fucked as she strokes cock http://ukwon01.businesscatalyst.com/BannerProcess.aspx?ID=15380&URL=https://michelejullian.info/cock/3902-sexy-office-girl-in-tights-having-cock-ass.php
5347 kimmy granger and biography at the sexbomb http://maritalhealing.priestlyhealing.com/exitsite.php?externalurl=https://michelejullian.info/brunette/10999-brunette-pornstar-samantha-ryan-providing-business-executive-with-sex.php
9841 jessie rojers fucked in bathroom tub amazing babe hardcored http://www.om1.ru/go/michelejullian.info/cock/10518-russian-creampie-anal-big-cock-blonde-european-internal-cumshot.php
16560 big tits unshaved hairy teen http://archivipress.europelectronics.net/rban300clicwebR.php?u=https://michelejullian.info/teen/6883-german-teen-marina.php&p=1234WEBR5678
1961 bigtits blonde milf hottie julia ann gets impaled by manding http://m.courtesylimo.com/analytics/hit.php?nocache=1555842009.6&r=cutepix.info%2fsex%2friley-reyes.php&a=9&i=13622716&r2=https%3a%2f%2fmichelejullian.info%2fcock%2f17672-latina-latino-santa-cock-riding-with-hot-redhead-teen.php
2048 exotic teen with dyed hair sucking this guy massive cock https://3dgeoinfoconference2019-dot-yamm-track.appspot.com/Redirect?ukey=1hRj0mBCxQalLdsmEXTEpxE_-l_exgYHzmxeHT3rSy2A-0&key=YAMMID-43090508&link=https%3a%2f%2fmichelejullian.info%2ftits%2f23413-pregnant-vicky-pours-milk-over-her-swollen-tits-freeones.php
5322 wow girls anjelica dominique maria pie nancey rossy in invites https://www.lusauto.com/Catalog/SwitchLang?Lang=es&ReturnUrl=https://michelejullian.info/anal/12210-pov-jugg-fuckers-empire.php
9110 facial with jazmine jarako http://www.hc.lv/link/?link=https://michelejullian.info/stockings/19112-ariel-piperfawn-cute-young-beautiful.php
18938 agathe teenager toying http://www.zusdmc.lviv.ua/golink.php?go=https://michelejullian.info/teen/4627-redly-redhead-beauty.php
13028 big titted milf waits in nude for her hubby to come home with legs spread http://www.hsi-chang-lai.com.tw/admin/Portal/LinkClick.aspx?tabid=114&table=Links&field=ItemID&id=434&link=https://michelejullian.info/stockings/8737-kat-shiny-dolls-naughty-teen-in-latex-panties.php
14021 teeny amateurschlapen lutschen http://doublejbllc.com/__media__/js/netsoltrademark.php?d=michelejullian.info/sexy/21217-nude-ariana-marie-and-recent-posts.php