Solved

jQuery - insert <br> in each paragrapher

Posted on 2014-10-13
7
401 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

821 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