Solved

jQuery - insert <br> in each paragrapher

Posted on 2014-10-13
7
283 Views
Last Modified: 2014-10-13
Hi E's, I need to know how I do a cycle in jQuery, and in each call I need to insert in code two br's, like <br><br>.
Initially I have this code:
<ul class="list-inline text-center articles">
    <i><a class="link_listar_artigos" href="praias-douradas-mas-ventosas">praias douradas mas ventosas</a></i>
    <i><a class="link_listar_artigos" href="grandes-ferias">grandes ferias</a></i>
    <i><a class="link_listar_artigos" href="lorem-ipsum">Lorem ipsum pt</a></i>
    <i><a class="link_listar_artigos" href="comida-marroquina">comida marroquina</a></i>
</ul>

Open in new window

and this should be the final code:
<ul class="list-inline text-center articles">
    <i><a class="link_listar_artigos" href="praias-douradas-mas-ventosas">praias douradas mas ventosas</a></i>
    <br><br>
    <i><a class="link_listar_artigos" href="grandes-ferias">grandes ferias</a></i>
    <br><br>
    <i><a class="link_listar_artigos" href="lorem-ipsum">Lorem ipsum pt</a></i>
    <br><br>
    <i><a class="link_listar_artigos" href="comida-marroquina">comida marroquina</a></i>
    <br><br>
</ul>

Open in new window

How I insert the br's in the code like above?

The best regards, JC
0
Comment
Question by:Pedro Chagas
  • 3
  • 3
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40377683
Are they supposed to be LI's not I's?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40377705
$(".articles li").each(function(){
    $(this).after("<br><br>")
})

Open in new window

0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 40377744
Hi @Gary, I will explain.
I create a responsive blog, where have different behaviors depending the device, but also I will create different behavior for the orientation of the device, can be portrait or landscape. In this picture, this is the behavior in landscape orientation:13-10-2014-19-12-33.pngIn this case the behavior of landscape orientation is show article name under article name, li paragrapher. But when the orientation is portrait, I'd like to put the name of articles consecutive, like no paragrapher's. Maybe have a better solution, and what I think for that objective, was, when the orientation is landscape the br's are in code, but when is portrait orientation I remove the br's.

To answer your question, yes, missing "li", that's because I try to do some experiences, and I forgot to replenish the initial code. But the with li tag, I think, I cant show the articles name in consecutive. So the new code is this one:
<ul class="list-inline text-center articles">
    <a class="link_listar_artigos" href="praias-douradas-mas-ventosas"><i>praias douradas mas ventosas</i></a>
    <br><br>
    <a class="link_listar_artigos" href="grandes-ferias"><i>grandes ferias</i></a>
    <br><br>
    <a class="link_listar_artigos" href="lorem-ipsum"><i>Lorem ipsum pt</i></a>
    <br><br>
    <a class="link_listar_artigos" href="comida-marroquina"><i>comida marroquina</i></a>
    <br><br>
</ul>

Open in new window

What is the best solution for my case?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Author Comment

by:Pedro Chagas
ID: 40377751
I will test your last solution. which will now be so:
$(".articles a").each(function(){
    $(this).after("<br><br>")
})

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 400 total points
ID: 40377755
Change the UL to a div

http://jsfiddle.net/beez1xqp/1/
0
 
LVL 19

Assisted Solution

by:Albert Van Halen
Albert Van Halen earned 100 total points
ID: 40378139
Consider css media queries.
Have a look here: http://jsfiddle.net/m01gtjw0/

In order to see how it behaves you can resize the screen.
Perhaps it's not what you want exactly but it illustrates the use and power of media queries.
You just have to create the rules for different modes.
0
 
LVL 3

Author Closing Comment

by:Pedro Chagas
ID: 40378749
Thank you @Gary for the solution.
Thank you @Albert Van Halen for the great idea.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now