Tab with jquery

2

How do I tabulate a sentence and put it one underneath the other? Let me explain: I'm using this code to add inside a div:

<script type="text/javascript">
$(document).ready(function() {

  $('#cbo_vitrine').change(function(){ 

  itemsel = $("#cbo_vitrine option:selected").text();

           if(itemsel == "REF-01")

                $("#det_prod_vitrine").append("FLOR BATIDO - MARROM - Nº: 23 ao 41 - R$34,99");

           if(itemsel == "REF-02")

                $("#det_prod_vitrine").append("MEDALHÃO - MARROM - Nº: 33 ao 44 - R$34,99");

           //if(itemsel == "REF-...")       
   });  
});
</script>

I select in a select and go adding with append. It's just getting kind of pummeled. Detail: I'm not bringing any database, but it's static. Does anyone suggest something more practical or guide me to tabulate ??? Thank you teachers.

    
asked by anonymous 08.06.2018 / 02:03

1 answer

0

You can include the phrase in a div , for example, because div occupies the full width of the line, making each phrase a single line:

$(document).ready(function() {

  $('#cbo_vitrine').change(function(){ 

  itemsel = $("#cbo_vitrine option:selected").text();

           if(itemsel == "REF-01")

                $("#det_prod_vitrine").append("<div>FLOR BATIDO - MARROM - Nº: 23 ao 41 - R$34,99</div>");

           if(itemsel == "REF-02")

                $("#det_prod_vitrine").append("<div>MEDALHÃO - MARROM - Nº: 33 ao 44 - R$34,99</div>");

           //if(itemsel == "REF-...")       
   });  
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><selectid="cbo_vitrine">
   <option>REF-01</option>
   <option>REF-02</option>
</select>
<div id="det_prod_vitrine"></div>

Or break the line with a <br> at the end of the sentence:

$(document).ready(function() {

  $('#cbo_vitrine').change(function(){ 

  itemsel = $("#cbo_vitrine option:selected").text();

           if(itemsel == "REF-01")

                $("#det_prod_vitrine").append("FLOR BATIDO - MARROM - Nº: 23 ao 41 - R$34,99<br>");

           if(itemsel == "REF-02")

                $("#det_prod_vitrine").append("MEDALHÃO - MARROM - Nº: 33 ao 44 - R$34,99<br>");

           //if(itemsel == "REF-...")       
   });  
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><selectid="cbo_vitrine">
   <option>REF-01</option>
   <option>REF-02</option>
</select>
<div id="det_prod_vitrine"></div>
    
08.06.2018 / 02:08