1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

jQuery Help - Need to write some syntax

Discussion in 'jQuery' started by AD Huni, Jan 10, 2014.

  1. #1
    Hi,
    I need some help to write display values in a variable from a page using jQuery, also how to write the functions for that..
    Var1 - I need to display the name which we are selecting in drop down (on change)
    Var2- I need to pull “product id” of product page (onload/click)
    Var3- needs to display “product id” value in var3 if form submitted successfully (successful submit).
    Can someone please help me on this to write syntax on this.
    Thanks in Advance
     
    AD Huni, Jan 10, 2014 IP
  2. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #2
    HuggyStudios, Jan 11, 2014 IP
  3. AD Huni

    AD Huni Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    Hi I just wanted to know how to pull a value in var

    var1 = jQuery("Here what i need to use class? or id?").this() , if use class what syntax should i use or if use id?
     
    AD Huni, Jan 13, 2014 IP
  4. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #4
    You use this code for that:

    
    $('.class-name');
    $('#id-here');
    
    Code (markup):
     
    HuggyStudios, Jan 13, 2014 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    Also take note that getting the content might differ slightly depending on what you're trying to do. It might be
    $('.class-name').text(); or it might be $('.class-name').val();
    or the same for ID:
    $('#id-name').text(); or $('#id-name').val();
    Also take note that if you do this for instance on a click-function, you need to specifically target the clicked item if using a class (or else you'll get all the content from all the items matching that class).
    Something like:
    $('.class-name').click(function() {
    $(this).val();
    })
     
    PoPSiCLe, Jan 15, 2014 IP