Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Form Element Targeting

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25150
    stoobs3k
    Member

    Hi,

    I’m new to jquery and wanted to know more information about targeting (selectors and such) form elements such as input, checkbox, select (and option) based on their values, classes or other values and based on that do something (probably an if statement).

    Anything you could tell me would be great.

    #59056
    Rob MacKay
    Participant

    Hey :)

    there are LOADS of options in this subject, jQuery gives you lots of ways. BUT to get you going, and all you will need for now, here is some advice!

    Think CSS. jQuery will select like you would select in to style in CSS.

    Example:

    <div id="TheBox" />
    <div class="TheBox" />
    <p>

    Ok I have a div with the ID of "TheBox", and a class of "TheBox" and a plain P – in css I would select like this…

    #TheBox { /* CSS Stuff */ }
    .TheBox { /* CSS Stuff */ }
    p { /* CSS Stuff */ }

    In jQuery you do this…

    $("#TheBox")
    $(".TheBox")
    $("p")

    you can even drill down to select things, or multipul items like in CSS…

    $("#one, #two, #three")

    <div id="one" />
    <div id="two" />
    <div id="three" />

    $("#one #two)

    <div id="one">
    <div id="two" />
    </div>

    Hope that helps :)

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.