Solved

jQuery - insert <br> in each paragrapher

Posted on 2014-10-13
7
406 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to implement server side field validation and display customized error messages to the client.
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)

734 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