How to make div hidden by default created by content_tag_for

I made a div through content_tag_for, and I want to make it hidden by default. How should I do it? I also use jquery.

+3
source share
2 answers

Join class:

content_tag_for(:div, @person, :class => "hidden") { # blah blah }

And define it as hidden in the stylesheet:

div.hidden { display: none }

Note. You can also use div_forthat saves some code. See the API .

+5
source

Would this work as you mention using jQuery?

In the HEAD page:

<script>
$(document).ready(function() {
  $('#your-div-id').hide();
});
</script>

Or in a BODY page AFTER creating a div, simply:

<script>
  $('#your-div-id').hide();
</script>

Or I do not understand your question? Thank.

+2
source

Source: https://habr.com/ru/post/1780937/


All Articles