views:

17

answers:

1

Ok, so i'm trying to create an address out of some bits of code from another spot on the page. The code i'm trying to create the address from is this:

<div class="adr">
  <h3 class="name fn">Boardwalk Audi<div class="separator">|</div></h3>
  <h4 class="street street-address">5930 West Plano Pkwy</h4>
  <h4 class="city">
  <span class="locality">Plano</span>, </h4>
  <h4 class="state region">Texas</h4>
  <h4 class="zipCode postal-code">75093</h4>
</div>

Basically i want to select these elements with JQuery and format them into something that will output as text onto the page somewhere else in the format style below:

Boardwalk Audi 5930 West Plano Pkwy, Plano, Texas, 75093

Anyone know how i can do this?

Thanks!

+1  A: 

Something like this? http://jsfiddle.net/YJrzn/

$('#response').text($('.name', '.adr').text() + ' '
        + $('.street', '.adr').text() + ', ' + $('.locality', '.adr').text() 
        + ', ' + $('.state', '.adr').text() + ' ' + $('.zipCode', '.adr').text());​
Robert
Perfect, exactly like that! Thanks!
RyanPitts
Is there a way to set just the ".name" into one variable and the rest to another variable?
RyanPitts
nevermind, i think i figured it out :)
RyanPitts