[jQuery] Re: Calling an element tag and the value inside one of it's attributes

2009-05-04 Thread Andy H

For some reason this post disappeared.  Can anyone answer this?

Thanks!



On May 1, 10:01 am, Andy adharb...@gmail.com wrote:
 This is an odd questions.  I have a huge form with a lot of data.
 There is a table that data in it I need to display on a print screen
 (of course this data isn't being displayed in the regular table).  So,
 I put the display text in a span tag.

 So, this is how each item will look:

 span printData=Item 1 detail to displayItem 1/span
 span printData=item 2 detail to displayItem 2/span

 I need a way to grab all spans on the page that have the attributte of
 printData and grab that text inside that attribute and print it out.

 Any thoughts?


[jQuery] Re: Calling an element tag and the value inside one of it's attributes

2009-05-04 Thread Andy H

Here is an actual example.  Would anyone know why this isn't working?
What I find weird is if I do a single line (alert($(span).attr
(printElement));) it works fine.  But if I try to use the each()
function following it, nothing happens.


Any help would be great.

Thanks!






HTML:

span printElement=this is for the first itemThis is the first span
1/spanbr /
span printElement=so is this oneThis is the first span 2/
spanbr /
spanThis is the first span 3/spanbr /
span printElement=Another item in hereThis is the first span 4/
spanbr /
spanThis is the first span 5/spanbr /
span printElement=asdf asdf  af aweThis is the first span 6/
spanbr /
span printElement=hello!This is the first span 7/spanbr /
span printElement=WorldThis is the first span 8/spanbr /
spanThis is the first span 9/spanbr /br /


Output:br /
div id=output/div




Javascript:

$(document).ready(function() {

//alert($(span).attr(printElement));

$(span).each(function() {
$(this).attr(printElement).each(function() {

});
});

}

On May 4, 1:33 pm, Andy H adharb...@gmail.com wrote:
 For some reason this post disappeared.  Can anyone answer this?

 Thanks!

 On May 1, 10:01 am, Andy adharb...@gmail.com wrote:



  This is an odd questions.  I have a huge form with a lot of data.
  There is a table that data in it I need to display on a print screen
  (of course this data isn't being displayed in the regular table).  So,
  I put the display text in a span tag.

  So, this is how each item will look:

  span printData=Item 1 detail to displayItem 1/span
  span printData=item 2 detail to displayItem 2/span

  I need a way to grab all spans on the page that have the attributte of
  printData and grab that text inside that attribute and print it out.

  Any thoughts?- Hide quoted text -

 - Show quoted text -


[jQuery] Re: Calling an element tag and the value inside one of it's attributes

2009-05-04 Thread Blaine

You need to read the jquery selector docs at
http://docs.jquery.com/Selectors/attributeHas#attribute


Below is the code that will get your data.
 $(span[printData]).text();



On May 4, 12:33 pm, Andy H adharb...@gmail.com wrote:
 For some reason this post disappeared.  Can anyone answer this?

 Thanks!

 On May 1, 10:01 am, Andy adharb...@gmail.com wrote:

  This is an odd questions.  I have a huge form with a lot of data.
  There is a table that data in it I need to display on a print screen
  (of course this data isn't being displayed in the regular table).  So,
  I put the display text in a span tag.

  So, this is how each item will look:

  span printData=Item 1 detail to displayItem 1/span
  span printData=item 2 detail to displayItem 2/span

  I need a way to grab all spans on the page that have the attributte of
  printData and grab that text inside that attribute and print it out.

  Any thoughts?


[jQuery] Re: Calling an element tag and the value inside one of it's attributes

2009-05-04 Thread Blaine

Expanding on my example below, with the each function.

First final all elements. Then do whatever you want with the element.

$(span[printData]).each( function( key, elementRef){
alert( $(elementRef).text() );
});

On May 4, 2:16 pm, Andy H adharb...@gmail.com wrote:
 Here is an actual example.  Would anyone know why this isn't working?
 What I find weird is if I do a single line (    alert($(span).attr
 (printElement));    ) it works fine.  But if I try to use the each()
 function following it, nothing happens.

 Any help would be great.

 Thanks!

 HTML:

 span printElement=this is for the first itemThis is the first span
 1/spanbr /
 span printElement=so is this oneThis is the first span 2/
 spanbr /
 spanThis is the first span 3/spanbr /
 span printElement=Another item in hereThis is the first span 4/
 spanbr /
 spanThis is the first span 5/spanbr /
 span printElement=asdf asdf  af aweThis is the first span 6/
 spanbr /
 span printElement=hello!This is the first span 7/spanbr /
 span printElement=WorldThis is the first span 8/spanbr /
 spanThis is the first span 9/spanbr /br /

 Output:br /
 div id=output/div

 Javascript:

         $(document).ready(function() {

             //alert($(span).attr(printElement));

             $(span).each(function() {
                 $(this).attr(printElement).each(function() {

                 });
             });

         }

 On May 4, 1:33 pm, Andy H adharb...@gmail.com wrote:

  For some reason this post disappeared.  Can anyone answer this?

  Thanks!

  On May 1, 10:01 am, Andy adharb...@gmail.com wrote:

   This is an odd questions.  I have a huge form with a lot of data.
   There is a table that data in it I need to display on a print screen
   (of course this data isn't being displayed in the regular table).  So,
   I put the display text in a span tag.

   So, this is how each item will look:

   span printData=Item 1 detail to displayItem 1/span
   span printData=item 2 detail to displayItem 2/span

   I need a way to grab all spans on the page that have the attributte of
   printData and grab that text inside that attribute and print it out.

   Any thoughts?- Hide quoted text -

  - Show quoted text -