Grow your CSS skills. Land your dream job.

jQuery – How to find what the text is inside an element.

  • # October 10, 2008 at 1:04 pm

    I was trying to figure out how to get the text off a page in a <TD> with a Class. That way I can do a conditional statement on the return value such as either hide or show another DIV.

    I tried the following with no luck:

    Code:
    jQuery.noConflict();
    jQuery(document).ready(function(){

    var giftopt = jQuery(“#giftopt”);

    if (“#giftopt == ‘Someone Else'”) {
    //do something
    };
    if (“#giftopt == ‘Me'”) {
    //do something
    };
    });

    # October 10, 2008 at 2:06 pm

    You use the .text() function to get the text out of an element

    http://docs.jquery.com/Attributes/text

    Code:
    var testText = $(“td#giftopt”).text();
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".