ruby on rails - How do I assign styling to a Javascript variable? -
ruby on rails - How do I assign styling to a Javascript variable? -
i have simple, dynamic email form field. after user submits email, receive message 'got it!'. need string "got it!" have same styling <p>
tag in css.. don't know how assign properties in javascript, , other part of code in ruby , don't know either. it's simple fix, can't find answer!
here javascript:
var finaltext = 'got it!'; // create new div contain our give thanks stuff var thankyoudiv = document.createelement("div"); thankyoudiv.id = "home_thankyou"; thankyoudiv.innerhtml = finaltext; // store reference formm var form = document.getelementsbytagname("form")[0]; // add together new thankyoudiv before form form.parentnode.insertbefore( thankyoudiv, form ); // remove form tag alltogether form.parentnode.removechild(form);
and here html/ruby code:
<%= form_for :home, :remote=>true, :update=>"emailsubmit", :url => {:controller=>"home", :action=>"create"} |f| %> <div id=emailsubmit><%= email_field("infosignup", "email", :placeholder=>"enter email") %></div> <%= submit_tag("", :id=>"arrow2") %>
any help?
it isn't javascript need style, rather <div>
in write it.
assign class new div:
// create new div contain our give thanks stuff var thankyoudiv = document.createelement("div"); thankyoudiv.classname = "someclass"; thankyoudiv.id = "home_thankyou"; thankyoudiv.innerhtml = finaltext;
then in css, define class same rules you've defined <p>
:
p, .someclass { color: red; }
javascript ruby-on-rails css ajax
Comments
Post a Comment